Fetch fans from a Facebook Page
So, this is my scenario: I have to fetch all the fans from a Facebook Page, but the Graph API don't have any method to do this.
I searched whole Google and Stack Overflow and found a bug report where everyone saying it existed but Facebook discontinued for some problems. They are trying to fix, but no good news so far.
Then an (obvious) idea came to me: what about building a crawler to fetch the fans?
Anyone have an idea if Facebook allow this kind of information access? At l开发者_StackOverflow中文版east, until they fix the API.
The condition part of a FQL must contains an indexed field.
Here uid
is the indexed field of the page_fan
table. So we can't retrieve the data without using it.
SELECT page_id FROM page_fan WHERE uid=USER_ID
The above query only provides the ID of the page the user had liked.
After the detailed search for retrieving the fans details, I reached the conclusion that Facebook does not provide the fan's details because of security reasons.
There's nothing wrong with the Graph API, you just have to use another method for this matter. The solution is called FQL.
Facebook has a table called page_fan
(docs here) which you can use to find users who liked of a page fan (fans).
Let's take for example the page of The Coca Cola company. This page has the id 40796308305
. The query to get all the ids of fans of this page is:
SELECT uid FROM page_fan WHERE page_id=40796308305
Of course, you will need a valid acces_token to use this in your application. If you want to test live this query, use the following url:
https://api.facebook.com/method/fql.query?query=SELECT uid FROM page_fan WHERE page_id=40796308305&access_token=YOUR_ACCESS_TOKEN
Good luck!
This used to work using FQL like misterjinx posted but unfortunately no longer works and is not available with the Facebook graph api. There are lots of people commenting about it on the page_fan documentation page but no solution at the moment.
I used this for page_fan
https://api.facebook.com/method/fql.query?query=select+uid+from+page_fan+where+uid=732484576+and+page_id=171535666239724&access_token=135669679827333|siKaemNLpHRDuJVnUPeChZYko6c
Returns True each time.
A bit late, but if you havent found the solution, all you need to do is get the number from http://graph.facebook.com/cocacola
change cocacola for the facebook ID you want to collect fans for.
精彩评论