Facebook fan count on a given date - facebook

I am not a programmer and I have literally no idea about the Facebook API. However, I need to collect some data from six different Facebook pages for my thesis, and I'm not the admin of them.
I've managed to get all the statuses, likes, comments of the 6 Facebook pages from a year using:
https://api.facebook.com/method/fql.query?query=select permalink,like_info,comment_info,share_info,created_time from stream where source_id={fan-page-ID} and created_time < {time-in-Unix-timestamp} and actor_id={fan-page-ID} ORDER BY created_time DESC LIMIT 20000&access_token ={your-access-token}
Now I need to get the number of fans the six pages had during the year (the variation). I would like to know how many fans the page had on a certain date. I've found this:
http://api.facebook.com/method/fql.query?format=xml&query=select fan_count,name from page where page_id={fan-page-ID}
And it works but it gives me the number of fans for today, not a certain date that I want. Any idea how can I achieve that? It would be amazing if I could get an XML so I can open it in excel for further analysis.

Related

How to get total number of likes on page posts

Is there a simple way to get the number of likes on posts on a page from the facebook graph API. My current Aproach is to get the feeds of the page, and then for each individual post get the ammount of likes.
So First I itterate all the posts on
--This make this a ton of times as I can only retrive 100 at a time
/{page-id}/feed
And then using each post ID
--Make this request even more times
/{object-id}/likes?summary=true
But this is horribly inneficient and takes a lot for each page.
So basically the question is, can I get the info making less requests?
This works for me:
/{page-id}/posts?fields=message,likes.limit(1).summary(true)

Unable to get actual likes of Facebook Page

I use
https://developers.facebook.com/tools/explorer?method=GET&path=fiatNL
to check the page likes of the Dutch Fiat Facebook page. The likes that are displayed are the combined likes of all Fiat Facebook pages together (over 1 million). I know that the Dutch Fiat page has no more than 50k likes.
If I check the brand children with this query:
https://developers.facebook.com/tools/explorer?method=GET&path=fiat%3Ffields%3Dglobal_brand_children.fields(name%2Clikes)
It still shows the combined likes.
Is there a way to check the likes of each brand child seperately?
I don't think it's possible because if you likes the page at https://www.facebook.com/fiatnl/, you're automatically likes the other page at https://www.facebook.com/fiatdk/ too.
This pages likes is sync:
If you unlikes the page at https://www.facebook.com/fiatnl/, the other page at https://www.facebook.com/fiatdk/ become unlike too.
Update:
You can try to request (110630838997361 is the page id of http://www.facebook.com/fiatnl):
SELECT value FROM insights where object_id='110630838997361' and
metric='page_fans_country' and period='0' AND end_time =
end_time_date('2014-01-12')
Based on documentation at https://developers.facebook.com/docs/reference/fql/insights/, i don't know why i have to specify end_time when period is 0:
However, this query would return the total likes of each country, so you can simply sum the total.
Page id 53829903566 (http://www.facebook.com/fiatdk):
Page id 110630838997361 (http://www.facebook.com/fiatnl):
Note: end_time_date('2014-01-12'), you cannot do end_time_date('2014-01-13') because it return empty results, so you may consider adjust a bit the current date:

Facebook Graph API: Get all posts from all the pages the user likes

I want to get all the posts from all the pages from the user /me/home feed.
Right now Facebook is deciding for the user what posts will get to the feed and which ones will not.
For example, if the user is subscribed (likes) 100 pages and all 100 of them posts an update the user feed will not show all 100 of them, only a portion of updates that it thinks important. Neither the API.
Is it possible to get all updates using the Graph api (like a regular timeline)?
You can try FQL, for example:
{"query1":"SELECT type,post_id,created_time,actor_id,target_id,message,attachment.media,attachment.caption,attachment.name,attachment.description,attachment.fb_checkin,likes.count,likes.user_likes,likes.can_like,comment_info,description FROM stream WHERE filter_key='pp' AND created_time<now() ORDER BY created_time DESC","query2":"SELECT id,name,pic FROM profile WHERE id IN (SELECT actor_id,target_id FROM #query1)"}
The keyword was filter_key='pp', means that you want to get all page's news feed.
I have no idea it will include ALL of 100 pages on real time, however this should be enough to achieve your goal. One more point, news feed have 1 week limitation, means that you cannot query older than 1 week's news feed.
Update:
https://graph.facebook.com/me/home?filter=pp is alternative way if you don't want to use FQL.
Use the following FQL in your https request to get the list of all likes paginated
SELECT src_big, src_small, owner,caption FROM photo WHERE object_id IN (SELECT object_id FROM like WHERE user_id == me() LIMIT 10 OFFSET 8 )

How to get all people who liked Facebook post?

I have FB post
I can click "77 people like this" and get all people I needed.
Question: is there way to get these people by FB API ?
PS I want to get 3 random names from these list so I need to have these people in JSON format
It's easy to do with FQL. This gets you three random ids of people who liked this event
SELECT user_id FROM like WHERE object_id = 336638873112346 ORDER BY rand() LIMIT 3
If you wanted to get their names instead, you'd rewrite the query like this:
SELECT uid, name, username FROM user WHERE uid IN
(SELECT user_id FROM like WHERE object_id = 336638873112346 ORDER BY rand() LIMIT 3)
I'm one of the co-founders of Kither, a platform for checking all of your Facebook stats. We have added many features which requires to fetch all of our user's posts likes.
As of August 6, 2016, FQL is deprecated.
Facebook's Graph API's still available and you can call https://graph.facebook.com/{api-version}/{post-id}/likes to get likes on posts. But remember, Facebook uses pagination on likes if there are more than 1,000 of them.
Now, In this case you'll need to call the next page url.
You'll need to call the next url unless you've got all the likes. (you won't find any next field if there are no more likes)
To get how many people have liked that post (i.e. count), you don't need to page through results. You can simply use https://graph.facebook.com/{api-version}/{post-id}/likes?summary=true and you'll get an extra field containing all likes' summary, including their count.
Same can be done with comments and recently added, reactions.

How to get page fan count from last week

I want to get the number of new facebook fans for a given page from last week.
e.g.: monday to sunday of previous week.
I have searched for this but can't find any info.
I can get the total fan count easily from the social graph but not sure how to get new fan count from last week so that I can get a report like:
New fans last week: 152
Total fans: 2341
You have to be admin of that page, and you need the "read_insights" permission. Without user authorization you don´t have access to the Insights, and that´s the only way to get detailed statistics.
https://developers.facebook.com/docs/reference/fql/insights/
Using FQL, it is explained here:
How to get `page_fan_adds` for multiple days using FQL
A bit complicated, because you have to add the daily values. But on the same page, the much easier solution is presented:
bladauhu/insights/page_fan_adds/?since=1340175600&until=1342767600