Reputation: 907
I'm just getting started with a project and wondered if someone can let me know if it's possible to:
A) Get a list of all friends for an authorised Facebook account via the API
B) Get all of the likes for each friend using the API
I saw this code suggested on another question:
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);
})
})
But I'm struggling to understand the logic of this as it looks like you need to know the ids
to get the likes.
Also is there a limit to the number of likes returned? I read something about it only returning the last X
number of likes for each user.
Many thanks!
Upvotes: 2
Views: 4784
Reputation: 406
You can fetch all the friends for an authorized user with the friends.get API call. http://developers.facebook.com/docs/reference/rest/friends.get/
Once you have the list of friends, you can loop through the list and fetch their likes by using the graph API's "likes" call.
Graph API Documentation: http://developers.facebook.com/docs/reference/api/
Sample "likes" request: https://graph.facebook.com/put_a_fb_user_id_here/likes
Upvotes: 1