2

I would like to get all likes of a user's friend on Facebook. So far I know how to take all likes of an authenticated user by FQL query:

SELECT object_id, object_id_cursor,object_type, post_id, post_id_cursor, user_id FROM like WHERE user_id =me()

However I'd like to have similar information about ALL user's friends.
So the question is how to get all likes from user's friends. Does anybody can give me a hint on it?

Ivan T
  • 1,046
  • 1
  • 10
  • 22

2 Answers2

0

I don't think it's possible to get all with FQL, you need to get a list of the user's friends id's, and then run the query against each friend..

$friends = array(); //an array of user ids
foreach($friends as $value){
    //Create query
    $fql = "SELECT object_id, object_id_cursor,object_type, post_id, post_id_cursor, user_id FROM like WHERE user_id = $value";
}

However I don't think you want to go with FQL, you can do things in an easier manner using the graph API with batched requests (you'll end up with hundreds of API calls if you do this in FQL, and will probably end up with your APP blocked by facebook)

Mostafa Berg
  • 3,211
  • 22
  • 36
  • Thanks for a reply, however this approach does not work. When you insert an user_id in query FB returns "The indexed user_id queried on must be the logged in user" So it seems to be banned from Facebook – Ivan T Jun 15 '13 at 14:17
  • No, you probably don't have correct permissions, did you ask for the `friends_likes` permission ? – Mostafa Berg Jun 15 '13 at 14:22
  • No, basically I have all the permissions. You can try here yourself: https://developers.facebook.com/tools/explorer/ – Ivan T Jun 15 '13 at 14:25
  • Ok I've taken a look and you're right, you can only query the logged in user, so the only choice you have is using the graph API, and you better use batching cause you don't want to send too many calls, I've also flagged this as a duplicate of the following question, you can find the answer there :) http://stackoverflow.com/questions/4780586/how-to-get-friends-likes-via-facebook-api/5323807#5323807 – Mostafa Berg Jun 15 '13 at 14:42
  • This returns only likes related to pages, movies, etc. This can be done by FQL query: '{ "friends":"SELECT name, uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())", "friendsLikes":"SELECT uid, page_id FROM page_fan WHERE uid IN (SELECT uid FROM #friends)", "pages":"SELECT page_id, name FROM page WHERE page_id IN (SELECT page_id FROM #friendsLikes)" }' However I'm interesting in likes related to any kind of facebook objects: photos, links, albums, statuses, etc. However I'm interesting – Ivan T Jun 16 '13 at 10:17
0

So far you can take only URLs that your friends have liked. Here is the FQL request to do it:

SELECT url FROM url_like WHERE user_id={friendId}

All friend ids you can get by fql query or by API call.

Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
Ivan T
  • 1,046
  • 1
  • 10
  • 22