How can I retrieve the list of Facebook users that have clicked the like button on an external site?
Say I have a like button:
<fb:like href="http://example.com/xyz"></fb:like>
I'd like a list of FB user IDs of people who have liked it.
I've tried OpenGraph:
https://graph.facebook.com/OBJECTID/likes/
(where OBJECTID is the id of the like example.com/xyz)
and FQL
select user_id from like where object_id in (
select id from object_url where url = 'http://example.com/xyz'))
but both return empty results.
I can see from other calls that the likes are counted alright, but I can't get the actual users.
Anyone know what permissions etc. I'd need to retrieve these?
Also see this question for sample code.
The simple answer is 'Its not possible to get individual user ids who liked a page'.
https://graph.facebook.com/cocacola/likes?access_token='xxxxxxxxxxxxxxxxxxxxxxx'
will surely return the data about the likes from the user/page but not the list of users who liked the specific object(in this case coca-cola). But make sure you send a proper access_token with proper permissions.
The FQL like is used to get the likes of any objects like video, note, link, photo, or album. To get liked users count of a page please use either link_stat or page from FQL.
the sample query will be like
SELECT url, normalized_url, share_count, like_count, comment_count, total_count,
commentsbox_count, comments_fbid, click_count FROM link_stat WHERE url="facebook.com"
SELECT name, fan_count FROM page WHERE page_id = 19292868552
For more clear answers on this, please read the answer by Jonathan Dean in How to list facebook users who like a page or interest
or ifaour answer in Querying Users who 'like' my Facebook Page
Related
How can we get a list of facebook ids of all the people that like our page?
Can we write some kind of code that goes over the page and gets them?
You can't get a list of ALL the users who have liked a particular page using the Graph API or FQL.
However, you can get a count of number of users who have liked your page by using:
SELECT fan_count from page where page_id = {page_id}
And you can also check whether any of the user in your friend list has liked a particular page or not (this requires additional friends_likes permission). This can be done by using:
SELECT created_time from page_fan where
page_id = {page_id} AND uid IN (uid1, uid2, ...)
EDIT: Just found out there's already a discussion going on regarding this on Stack Overflow. Take a look at this question: Facebook API: Get fans of / people who like a page
I've got a facebook page which is publicly accessible. On my website I'd like to display the last post made by this page.
I made a script which uses the facebook php-api and FQL to retrieve the events from the page. But I just can't figure out how to construct a FQL which displays the latest posts from my page. I've seen the stream table and thought I should use it like this:
SELECT created_time,
likes, message, post_id, share_count, type
FROM
stream
WHERE
actor_id = {$page}
LIMIT 5
But that results in the fact I need a Starred/Indexable column. Fair enough, but I can't figure out which starred column to use.
Anybody?
You should use: source_id instead of actor_id
When I use https://developers.facebook.com/docs/reference/fql/link_stat
i got this informations like_count, commentsbox_count , share_count , comments_fbid
like_count is the number of times Facebook users have "Liked" the page, or liked any comments or re-shares of this page. can I only get the count of users who clicked on my like button page ?
You are already getting the like count, just make your fql as below
SELECT like_count FROM link_stat WHERE url=your_url
Recently I have created several facebook like button, each of them use iframe and href to link with an open graph object url. Then url will redirect the user into the facebook apps.
But, how can I get the like list from these open graph object? I have pass the urls into fql debugger and want to get the like list, it return nothing. Then I use graph API to check my open graph object page, it return the normal data without the like array list.
So now I cannot get the user id and their name, and I still don't know why I cannot get this... I saw some webpage in the facebook sample that can get the like list. This really make me down.
Due to privacy policies, there is no real way to extract this information.
You might get the friends list who liked the link, try this
SELECT user_id FROM like WHERE object_id IN (SELECT link_id from link WHERE url = 'YOUR URL HERE') and user_id IN ( SELECT uid2 FROM friend WHERE uid1 = me() )
You can use this query to get the fan count of your page.
select fan_count from page where page_id = 'page_id'
You can't list down all the users of your page. Instead you can check if a particular user is your page's fan or not using this query.
select uid from page_fan where uid = 'user_id' and page_id = 'page_id'
If I put a facebook like button on a webpage, can I use FQL to query the number of users that 'liked' the page?
Yep. Try the following FQL:
SELECT like_count FROM link_stat WHERE url="http://your-web-page-url";
There's more stats available from the link_stat table as well. The table reference is here.