facebookfacebook-graph-apifacebook-like

How to get all people who liked Facebook post?


I have FB post
I can click "77 people like this" and get all people I needed.
Question: is there way to get these people by FB API ?
PS I want to get 3 random names from these list so I need to have these people in JSON format


Solution

  • It's easy to do with FQL. This gets you three random ids of people who liked this event

    SELECT user_id FROM like WHERE object_id = 336638873112346 ORDER BY rand() LIMIT 3
    

    If you wanted to get their names instead, you'd rewrite the query like this:

    SELECT uid, name, username FROM user WHERE uid IN 
     (SELECT user_id FROM like WHERE object_id = 336638873112346 ORDER BY rand() LIMIT 3)