2010-06-01 50 views
0

我有我的朋友的名單,我可以遍歷集合按照我的要求列出它們。但是我想在不同的頁面上展示他們,因爲myspace上的人可能有超過100的朋友,所以我不想在同一頁面上展示他們。什麼是以頁面形式顯示它們的最佳方式。使用opensocial以頁面格式列出朋友的最佳方式是什麼?

目前我在做以下操作:

<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> 

回答

相關問題