0

我有我朋友的名单,我可以遍历收藏,按照我的要求列出他们。但是我想在不同的页面上显示它们,因为我空间上的人可能有超过 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>
4

1 回答 1

0

我通过使用以下链接做到了这一点:

http://www.l-exp.com/top/s/Technology/Internet/feedsc/newsletter&wpisrc=newsletter?page=124

于 2010-06-04T10:55:29.213 回答