使用Facebook API获取所有朋友和他们的赞


Get all friends and their likes using the Facebook API

我刚开始一个项目,想知道是否有人能告诉我是否可以:

A) 通过API 获取授权Facebook帐户的所有好友列表

B) 使用API 为每个朋友获取所有赞

我在另一个问题上看到了这个代码:

FB.api("/likes?ids=533856945,841978743")
FB.api("me/friends",{
  fields:'id',
  limit:10
},function(res){
  var l=''
  $.each(res.data,function(idx,val){
     l=l+val.id+(idx<res.data.length-1?',':'')
  })
  FB.api("likes?ids="+l,function(res){
      console.log(res);
  })
})

但我很难理解这其中的逻辑,因为看起来你需要知道ids才能获得点赞。

返回的点赞数量也有限制吗?我读到一些关于它的内容,只返回每个用户的最后一个X点赞数。

非常感谢!

您可以通过friends.get API调用为授权用户获取所有好友。http://developers.facebook.com/docs/reference/rest/friends.get/

一旦你有了朋友列表,你就可以循环浏览列表,并通过使用图形API的"点赞"调用来获取他们的点赞。

图形API文档:http://developers.facebook.com/docs/reference/api/

"点赞"请求示例:https://graph.facebook.com/put_a_fb_user_id_here/likes