Hi aptas,

Hmm... I seem that the working of Container#getTotalSize() is good.
You will be able to get the count of your friends by calling the
getTotalSize() method of 'viewer_friends' variable.
I want you to try following code if failing.

Best regards,
Yoichiro

---
<?xml version="1.0"?>
<Module>
  <ModulePrefs title="getTotalSize Test"
author_email="[EMAIL PROTECTED]">
    <Require feature="opensocial-0.7" />
  </ModulePrefs>
  <Content type="html" view="canvas">
    <![CDATA[
<script type="text/javascript">
function init() {
  var req = opensocial.newDataRequest();
 
req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS)
, "viewer_friends");
  req.send(onInit);
}
function onInit(data) {
  var viewerFriends = data.get("viewer_friends").getData();
  alert(viewerFriends.getTotalSize());
}
gadgets.util.registerOnLoadHandler(init);
</script>
    ]]>
  </Content>
</Module>
---

On 6月26ζ—₯, 午後8:44, aptas <[EMAIL PROTECTED]> wrote:
> Hi..
> I am trying to format the list of friends which I have fetched using
> the orkut API.
> I am trying to get the total number of friends (friend count) so that
> I can loop it and arrange the friends (3-4 friends in one row).
> I tried using getTotalSize() but it is not working. Can you please
> suggest me how to do it.
> I am pasting the code below.
>
> Thanks so much
> *******************************************************************************
>       _IG_RegisterOnloadHandler(request);
>
>       function request() {
>         var req = opensocial.newDataRequest();
>
>         var opt_params = { };
>                 opt_params[opensocial.DataRequest.PeopleRequestFields.MAX] = 
> 9999;
>
> opt_params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS]
> = [
>           opensocial.Person.Field.PROFILE_URL
>         ];
>
> req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER,
> opt_params), "viewer");
>
> req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS,
> opt_params), "viewer_friends");
>         req.send(response);
>       }
>
>       function response(data) {
>         var viewer = data.get("viewer").getData();
>         var name = viewer.getDisplayName();
>         var thumb =
> viewer.getField(opensocial.Person.Field.THUMBNAIL_URL);
>         var profile =
> viewer.getField(opensocial.Person.Field.PROFILE_URL);
>
>         var html = '<a href="' + profile + '" target="_top">' + name +
> '</a><br><img src="' + thumb + '"/>';
>
>         html += '<hr>';
>
>         var viewer_friends = data.get("viewer_friends").getData();
>         viewer_friends.each(function(person) {
>           var thumb =
> person.getField(opensocial.Person.Field.THUMBNAIL_URL);
>           var profile =
> person.getField(opensocial.Person.Field.PROFILE_URL);
>
>           html += '<a href="' + profile + '" target="_top"
> style="float:left">' +
>                   '<img src="' + thumb + '" class="friendspic"/>' +
>                   '</a>';
>                   html+= '<br/>' + person.getDisplayName();
>         });
>
>         document.getElementById('main').innerHTML = html;
>       }
>
> *******************************************************************************
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Orkut Developer Forum" group.
To post to this group, send email to opensocial-orkut@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/opensocial-orkut?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to