Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

API for getting total number of likes of a facebook page

Tags:

php

facebook

I am looking for a way to keep track of my facebook page's number of likes every day. Is there an API for it? or any other way?

Thanks.

like image 716
TamTam Avatar asked Jan 20 '11 14:01

TamTam


People also ask

What data can I get from Facebook API?

With the Facebook Graph API, you can access a wide range of user data, including user information such as name, email address, birthday, and friends list in JSON. You can also access information about pages that a user has liked or engaged with on Facebook, as well as events and photos that they have posted or shared.

How do I get Facebook Page Insights on graph API?

You can access Page Insights by typing /insights after the name of your page in the URL field. This command will retrieve all of the Insights associated with your Page. Type "/insights" after your company name. Click the Submit button.

How do I get a list of Facebook API pages?

Call the Graph API - https://graph.facebook.com/me/accounts. You can test this procedure in the graph explorer -> Just click on 'Get Access Token' button-> under 'Extended permission' check 'manage_pages' & submit it. It will give you the admin-page-details JSON.


2 Answers

You can do it in an even easier way with the Facebook Graph API - it just returns JSON data, like so : http://graph.facebook.com/225397695229/

Where 225397695229 is the page or user ID you're referring to on FB. Just scroll to the bottom of the array and look for "likes".

Edit - 9/4/2015 -
Looks like an access token is required now in Facebook Graph 2.4 - so, appended to the URL would be &access_token={token_id}. Details on obtaining a Page token are here: https://developers.facebook.com/docs/facebook-login/access-tokens#pagetokens

like image 89
jpea Avatar answered Sep 29 '22 05:09

jpea


If you are the admin of the page, you should already have access to the Facebook Insights which would provide you that information and even more!

If you want to programmatically access these data, you need to create an application, grant a read_insights and maybe offline_access permissions and then it's an easy api call:

$facebook->api("/$page_id/insights");
like image 31
ifaour Avatar answered Sep 29 '22 05:09

ifaour