使用opensocial以分页格式列出朋友的最佳方式是什么?

时间:2010-06-01 07:57:45

标签: javascript opensocial myspace

我已经获得了我的朋友列表,我可以遍历该集合,根据我的要求列出它们。但我想在不同的页面中显示它们,因为myspace上的人可能有超过100个朋友,所以我不想在同一页面上显示它们。什么是在页面中显示它们的最佳方式。

目前我正在做以下事情:

    <script type="text/javascript">
    function init()
    {
    //creating request to get the friends
     var request = opensocial.newDataRequest();
             var params0 = {};
                params0[opensocial.IdSpec.Field.USER_ID] = opensocial.IdSpec.PersonId.OWNER;
                params0[opensocial.IdSpec.Field.NETWORK_DISTANCE] = 1;
                var idspec = opensocial.newIdSpec(params0);
                request.add(request.newFetchPeopleRequest(idspec), "friends");
                request.add(request.newFetchPersonRequest("OWNER"), "get_owner");
      request.send(got_myfriends);
}
function got_myfriends(response0)
{
//document.getElementById('message').innerHTML += "TESTING" + response0.data;
var friends=response0.get("friends").getData().asArray();
//document.getElementById('message').innerHTML += " TESTING0";
 var owner = response0.get('get_owner').getData();
document.getElementById('message').innerHTML += " TESTING1--ownerid: " + owner.getId();
document.getElementById('message').innerHTML +=" Total friends found: " + friends.length;
      var id, image, name;
        for(var i = 0; i < friends.length; i++){
          id = friends[i].getId();
            image = friends[i].getField(opensocial.Person.Field.THUMBNAIL_URL);
            name = friends[i].getDisplayName();
      document.getElementById('friendsdiv').innerHTML += "<div style='display:inline;float:left;width:150px;'><input type='radio' name='friendid' value='" + id + "'>" +  name  +"<BR><img src='" + image + "'></div>"; 
        }


}
</script>

1 个答案:

答案 0 :(得分:0)