I'd like to get a list of users who like a certain page or a fan of it.
The FB API documentation states that you can only get the count of the fans of a certain page using the social graph, but not a list of the fans.
A discussion here Retrieve Facebook Fan Names suggests that one could use an FQL query like SELECT user_id FROM like WHERE object_id="YOUR PAGE ID"
to get the number of people who liked the page, but for the same page, it gives an empty response "{}".
So I was wondering if anyone has an idea if this can be done.
Tap Pages. Go to your Page and tap More. Tap Edit Settings, then tap People and Other Pages. Tap People Who Like This Page.
When someone likes a Page, they're showing support for the Page and that they want to see content from it. The Page will show up as being liked in the About section of that person's profile. When someone follows a Page, it means they may receive updates about the Page in their Feed.
We recommended that you use the /object/reactions endpoint to get like counts, if available.
There is a "way" to get some part of fan list with their profile ids of some fanpage without token.
https://www.facebook.com/{PAGENAME}
as in example below based on og tags present on the fanpage.<meta property="al:android:url" content="fb://profile/{PROFILE_ID}" />
And now is the best part: try to refresh (F5) the link in point 2.. There is a new full set of another fans of Coca-Cola. Take only uniques and you will be able to get some nice, almost full list of fans.
Why don't you use my ready PHP script to fetch some fans? :)
UPDATE 2016.04.30: Updated example script to use new methods after Facebook started to require access token to get public data from graph api.
function fetch_fb_fans($fanpage_name, $no_of_retries = 10, $pause = 500000 /* 500ms */){ $ret = array(); // prepare real like user agent and accept headers $context = stream_context_create(array('http' => array('header' => 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/49.0.2623.108 Chrome/49.0.2623.108 Safari/537.36\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\nAccept-encoding: gzip, deflate, sdch\r\nAccept-language: en-US,en;q=0.8,pl;q=0.6\r\n'))); // get page id from facebook html og tags for mobile apps $fanpage_html = file_get_contents('https://www.facebook.com/' . $fanpage_name, false, $context); if(!preg_match('{fb://page/(\d+)}', $fanpage_html, $id_matches)){ // invalid fanpage name return $ret; } $url = 'http://www.facebook.com/plugins/fan.php?connections=100&id=' . $id_matches[1]; for($a = 0; $a < $no_of_retries; $a++){ $like_html = file_get_contents($url, false, $context); preg_match_all('{href="https?://www\.facebook\.com/([a-zA-Z0-9\._-]+)" class="link" data-jsid="anchor" target="_blank"}', $like_html, $matches); if(empty($matches[1])){ // failed to fetch any fans - convert returning array, cause it might be not empty return array_keys($ret); }else{ // merge profiles as array keys so they will stay unique $ret = array_merge($ret, array_flip($matches[1])); } // don't get banned as flooder usleep($pause); } return array_keys($ret); } print_r(fetch_fb_fans('TigerPolska', 2, 400000));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With