Retrieve Facebook users who like a URL/web page

2019-03-01 08:36发布

问题:

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.

回答1:

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