Reading Facebook Insights - facebook-insights

I'm trying to read insights from a facebook page using Insights Table with FQL or with Graph API. I've noticed that the only public fields are page_fans_country and page_storytellers_fan_country. Are all the other fields visible only by the page admin? There isn't a way to read the page_fans metric for example?
Thank's.

If it´s not public, you need to be admin, of course. But if you just need the actual fan count, it´s easier to use the Graph API: http://graph.facebook.com/[vanity-url]/
Just put it in the Browser and you will get all public information of the page ("likes").
Of course you can also use the PHP or JS SDK:
//JavaScript
FB.api('/[vanity-url]', function(response) {
...
});
//PHP
$response = $facebook->api('/[vanity-url');

Related

Get "Post Count" from public page using Facebook Graph API

I want to get a number of posts from a page in last month. Is is possible with facebook graph API? Also FYI, i just have the access_token to interact with the Facebook API.
Also do anyone knows how to fetch the number of Page mentions in last month?
Thanks for your help in advance.
Try using Facebook's Page Insights using Facebook Graph API's :
https://developers.facebook.com/docs/graph-api/reference/insights/#page_posts
But please note that you need to be a page admin for this page, and you need to acquire a Page Access Token with the permissions 'read_insights'.
If you are not a page admin, then you can also do the same with an User Access Token or an App Access Token.
Steps:
`int postsCount = 0;
Use the following API query https://graph.facebook.com/{page-id}/posts and issue a reuquest.
Count the posts fetched. postsCount = postsCount + {the posts json array size}.
Store the cursor returned by the above API result. Use it to fetch the next page of Posts.
If the {the posts json array size} > 0, then goto step 3.
Notes:
I am sure that you can do it better with FQL, but I am guessing FQL is being deprecated.
I think there is a summary(true) annotation (https://graph.facebook.com/{page-id}?fields=posts.summary(true)) that you can use, but I couldn't get it working.
There is an API rate limit that you need to keep in mind. And do some throttling.
So, the moral of the story is that I am not sure if Facebook really wants you to crawl its Pages if you are not the Admin of the page. :-)

How can I make my timeline with Graph API?

I've studied Facebook API for several hours, and googled lots of pages. But I can not find the way get posts list just like my timeline on Facebook app.
I would like to make a Web app that show my timeline posts just like Flipboard. I found an API to get my "story" and "my friends list". But I can not even imagine how to retrieve my friend post that shown on my timeline.
Is it impossible to replicate my timeline on my web app? Only Flipboard can do that? Do you have any hint?
To access the current User's News Feed use the "User/Home" request as described in the API Documentation.
In order to gain access to the User's News Feed you will be required to gain the "read_stream" permission. For information on how to request the appropriate permission, read the Login, authorization and permissions section of the Getting Started guide.
The request to me/home will return an array of News Feed items, which are comprised of statuses, pictures, likes, etc. You can see an example of the result by using the Graph API Explorer.
Compare the results to your Timeline and they should be nearly identical (currently I believe Ads/Promoted Posts are excluded from the API)"
Play around with the Graph API Explorer:
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fhome
I had to change the permissions within the App and specifically give myself 'read_stream' access, but once that was complete I was able to run a '/me/home' Graph API GET Request and return a representation of my timeline. Good luck!
You can get the timeline this way:
$fb = new Facebook('{config}');
$fb->setDefaultAccessToken('{getAccesstoken}');
$request = $fb->get('/me?fields=feed.limit(10000){link}');
//
$graphObject = $request->getGraphNode();
return $graphObject;

How to get facebook page rss feed (everyone)

If you view facebook page, they are link left-bottom shows rss feed for facebook page, but unfortunately, the feed only shows status update by page owner, is there anyway to get feed from everyone who post the new status in the page....
There's another way to get the feed from a public Facebook page as RSS, which is entirely public and can be retrieved anonymously; i.e. requires no Facebook connect or other stuff. The format for the URL of the RSS feed is:
https://www.facebook.com/feeds/page.php?id=PAGE_ID&format=rss20
Where PAGE_ID is the Facebook ID of the page. Or even better, as JSON:
https://www.facebook.com/feeds/page.php?id=PAGE_ID&format=json
Use http://developers.facebook.com/docs/reference/api/, get the access_token like this: Facebook: post image and description to wall and in page album via php
These guys seems to be providing an API as well here - https://randomtools.io/developer-api/

after user authenticates FB app, how can you get all likes from a specific domain?

I have a website called example.com with several internal pages that are liked.
I created a FB app.
when a user authenticates the FB app, I want to fetch ALL user likes such as: example.com/page1, example.com/page2, etc.
(a single user can have up to 100+ likes on the internal pages of example.com) I essentially want to get all the liked URL's (and associated FB graph ID) the authenticated user has made on my example.com website.
is there a way to do this?
perhaps via a facebook.api call? or perhaps a FQL query? I am open to PHP or JS.
please help! thanks.
...fyi, My initial thought is to for each user, fetch ALL their likes, parse through each one to make sure it came from example.com, and then store those like URL's into a local database. when the user re-visits the site, I will query my database for likes associated with that user. this did not seem the most efficient as it would require storing all likes ever made on my website. any help would be much appreciated.
If you just want to store when a user likes a page on your website why not make use of the edge.create and edge.remove events the Facebook JS SDK provides? Example:
FB.Event.subscribe('edge.create', function(targetUrl, elm) {
// Make a request to server to save 'Like' information
});
FB.Event.subscribe('edge.remove', function(targetUrl, elm) {
// Make a request to server to remove 'Like' information
});
I see in the attributes of the like plugin, that the ref attribute might be what you could use to determine where a like came from. Of course your href attribute would need to be the same on all locations of the like button.
Or, you can register your site with facebook insights and track it there. See https://www.facebook.com/insights/
The User API reference is here: https://developers.facebook.com/docs/reference/api/user/
Here's how you get all the likes via the JS API (unless they're more than one page, they you get a subset of the likes):
FB.api('/me/likes', function(response) {
console.log(response);
});
You need to be logged in, and you need the user_likes permission.

Any way to pull likes by dates from facebook graph api? (New Likes instaed of Global Likes)

I basically need an access to a fanpage's likes by dates, i mean.. not the global likes when you access the graph but the ability to see how much likes the page got yesterday/today..
Any way to do that?
Have a look at https://developers.facebook.com/docs/reference/fql/insights/#page_users - you (by which I mean the user of your app) need to be admin of the page though. You get page_fans, *_adds, *_removes, etc.. On how to execute FQL using the Graph API: https://developers.facebook.com/docs/reference/fql/