It looks like there are several problems. There isn't a closing right
bracket on the opening ModulePrefs tag so the xml isn't valid.
There's a missing end quote in the line:
dataResponse.get('viewer_friends)
so you have an unterminated string literal. When you create the
request you should use opensocial.DataRequest.PersonId.VIEWER instead
of just VIEWER. You should use gadgets.util.registerOnLoadHandler()
to call your getData function at the appropriate time. Here's a
funcional, trimmed-down version of your code that just displays the
viewer name:
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Friends"
author="[EMAIL PROTECTED]"
description="Sample Friends data">
<Require feature="opensocial-0.7" />
</ModulePrefs>
<Content type="html">
<![CDATA[
<script type="text/javascript">
function getData()
{
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER),'viewer');
req.send(handleMyData);
};
function handleMyData(dataResponse)
{
var viewer = dataResponse.get('viewer').getData();
var html ="Friends of "+viewer.getDisplayName();
document.getElementById('message').innerHTML = html;
};
gadgets.util.registerOnLoadHandler(getData);
</script>
<div id="message" style="background-color:#EFEFEF;width:100px;">hello</
div>
]]>
</Content>
</Module>
On Apr 12, 4:17 am, sure <[EMAIL PROTECTED]> wrote:
> Hi to Everybody,
> I am new to this for groops. I am using
> GGE for developing Opensocial code. When ever i publishing my code it
> displays plain text. I wonder where should i did the mistake in my
> code. Everything is fine in my code. I checked my code so many times.
> But i didn't get any mistake. My helloworld program is working fine.
> Please help me.
> open.xml
> --------------
> <?xml version="1.0" encoding="UTF-8"?>
> <Module>
> <ModulePrefs title="Friends"
> author="[EMAIL PROTECTED]"
> description="Sample Friends data"
>
> <Require feature="opensocial-0.7" />
> </ModulePrefs>
>
> <Content type="html">
> <![CDATA[
> <script language="text/javascript">
> function getData()
> {
> var req = opensocial.newDataRequest();
> req.add(req.newFetchPersonRequest(VIEWER),'viewer');
> req.add(req.newFetchPeopleRequest(VIEWER_FRIENDS),'viewer_friends');
> req.send(handleMyData);};
>
> function handleMyData(dataResponse)
> {
> var viewer = dataResponse.get('viewer').getData();
> var html +="Friends of"+viewer.getDisplayName();
> html +=':<br /><ul>';
> var viewerFriends = dataResponse.get('viewer_friends).getData();
> viewerFriends.each(function(person)
> {
> html +='<li>'+person.getDisplayName()+'</li>';}
>
> );
> html +='</ul>';
> document.getElementById('message').innerHTML = html;};
>
> </script>
> <div id="message" style="background-color:#EFEFEF;width:100px;"></div>
> ]]>
> </Content>
>
> </Module>
> -------------------------
>
> Please let me know where should i did the mistake.
> It dosen't display my friends data. It displays plain page.
>
> Thanking u
> sure.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"OpenSocial Application Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/opensocial-api?hl=en
-~----------~----~----~----~------~----~------~--~---