Help with os:HttpRequest call

1 view
Skip to first unread message

Paresh Joshi

unread,
Apr 30, 2009, 2:26:59 AM4/30/09
to Orkut Developer Forum

<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Song List">
I had the profile code working with os:HttpRequest call in sandbox few
weeks back and noticed today that its broken. I could not figure out
why its broken (JSON content would not render), so tried the example
provided by orkut but I am not able to get the JSON content render
with their code as well.

I would greatly appreciate if anyone can provide pointers on how to
make this work.

Thanks,
Paresh

Here is how the application XML looks like:

<Require feature="opensocial-data" />
<Require feature="opensocial-templates">
<Param name="process-on-server">true</Param>
</Require>
</ModulePrefs>
<Content type="html">
<![CDATA[
<script type="text/os-data" xmlns:os="http://ns.opensocial.org/
2008/markup">
<os:HttpRequest key="song" href="http://www.vastunetwork.com/
orkut_profile.php"/>
</script>

</script>
<script type="text/os-template" require="song">
Test
<a href="${song.url}">
<img src="${song.albumThumbnail}"/>
${song.title} BY ${song.artist} FROM ALBUM ${song.album}
</a>
</script>
]]>
</Content>
</Module>

The JSON structure looks like:

{songs : [ { title: 'Love song #15', url: 'http://allmusic.com/johndoe/
greatesthits/lovesong15.mp3', artist: 'John Doe', album: 'Greatest
Hits', albumThumbnail: 'http://allmusic.com/johndoe/
greatesthits.jpg' }, { title: 'Love song #16', url: 'http://
allmusic.com/janedoe/greatesthits/lovesong16.mp3', artist: 'Jane Doe',
album: 'Best Of', albumThumbnail: 'http://allmusic.com/janedoe/
bestof.jpg' }, { title: 'Single #1', url: 'http://allmusic.com/janedoe/
greatesthits/single1.mp3', artist: 'Jane Doe', album: 'Greatest Hits',
albumThumbnail: 'http://allmusic.com/janedoe/greatesthits.jpg' }, ]}

Message has been deleted

eduardorochabr

unread,
Apr 30, 2009, 11:21:51 AM4/30/09
to Orkut Developer Forum
Try this:

<ul>
<li repeat="${osx:parseJson(songs.content)}">
<a href="${Cur.url}">
<img src="${Cur.albumThumbnail}"/>
</li>
</ul>

If it doesn't work, try removing ".content" and try again. The
'require="song"' doesn't seem to be needed.

Let me know if it works.

Paresh Joshi

unread,
Apr 30, 2009, 12:56:57 PM4/30/09
to Orkut Developer Forum

Thanks a lot for your reply. Unfortunately, I tried both version and
still did not work. Any other pointers will be greatly appreciated.

eduardorochabr

unread,
Apr 30, 2009, 1:23:43 PM4/30/09
to Orkut Developer Forum
Remember to declare the osx namespace:

<script type="text/os-template" xmlns:os="http://ns.opensocial.org/
2008/markup" xmlns:osx="http://ns.opensocial.org/2009/extensions">

Paresh Joshi

unread,
Apr 30, 2009, 1:34:53 PM4/30/09
to Orkut Developer Forum
Yup, Thanks!!...I saw your reply to another post and made that change
to add osx namespace..
Can you please take a look at the JSON object I am returning and let
me know if you see an issue with how data is being returned. Here is
the link that output JSON:
http://vastunetwork.com/orkut_profile.php

{songs : [ { title: 'Love song #15', url: 'http://allmusic.com/johndoe/
greatesthits/lovesong15.mp3', artist: 'John Doe', album: 'Greatest
Hits', albumThumbnail: 'http://allmusic.com/johndoe/
greatesthits.jpg' }, { title: 'Love song #16', url: 'http://
allmusic.com/janedoe/greatesthits/lovesong16.mp3', artist: 'Jane Doe',
album: 'Best Of', albumThumbnail: 'http://allmusic.com/janedoe/
bestof.jpg' }, { title: 'Single #1', url: 'http://allmusic.com/janedoe/
greatesthits/single1.mp3', artist: 'Jane Doe', album: 'Greatest Hits',
albumThumbnail: 'http://allmusic.com/janedoe/greatesthits.jpg' }, ]}

I really appreciate your help.
Thanks,
Paresh

Paresh Joshi

unread,
Apr 30, 2009, 1:44:19 PM4/30/09
to Orkut Developer Forum
Thanks a lot to your debugging tip in the other post...i got it to
work. I had to use

<li repeat="${osx:parseJson(songs.content.songs)}">

to get it to work.

I owe you one!!
Thanks,
Paresh

eduardorochabr

unread,
Apr 30, 2009, 1:50:20 PM4/30/09
to Orkut Developer Forum
The last "songs" must be outside the parenthesis:

<li repeat="${osx:parseJson(songs.content).songs}">

eduardorochabr

unread,
Apr 30, 2009, 1:57:21 PM4/30/09
to Orkut Developer Forum
Actually, debugging the app once again, I think we don't need to use
parseJson, it comes already parsed. So that would become:

<li repeat="${songs.content.songs}">
Reply all
Reply to author
Forward
0 new messages