How can I retrieve the number of fans my Facebook page had on a given day?
How can I retrieve the number of fans my Facebook page had on a given day? I am try开发者_高级运维ing to find a way to display a plot of date vs number of fans, but I can't find a way to get the number of fans by date.
I have tried this:
select active_users from metrics where end_time = 1263812045 and period = 2592000
in the Facebook developers tools page for my Page ( http://developers.facebook.com/tools.php ), but it retrieves an empty set.
Firstly: you can retrieve statistics such as active users for apps, but it won't tell you how many fans your page has. To retrieve fans you need to query the fan_count column of the page_fan FQL table, but you can't get historical data, only a total count. So you'll need to query it every day and build up your own database.
If, from the original query, you really wanted active users for an app, it's not particularly straightforward as the FQL query barfs at a lot of timestamps. The metrics FQL table documentation claims that you need to enter midnight PST timestamps, but I've found that it accepts 2am GMT and nothing else. E.g. select active_users from metrics where end_time = 1263715200 and period = 2592000
works for me on both apps and pages, but note as above: this retrieves an active user count and not the number of fans.
For people finding this question now: It's possible if you have read_insights permission. Then you can use FQL to query fan count, adds, removes and many other things:
https://developers.facebook.com/docs/reference/fql/insights/#page_users
You can execute FQL queries using https://graph.facebook.com/fql?q=THE%20Query
That's not possible, I'm sorry. You have to manually pull the data on a daily basis and write it to a database. That's the only way to create such a graph.
There's already a service called PageData.
SELECT fan_count, page_url FROM page WHERE page_id=1234567890"
精彩评论