Facebook: FQL for fetching all posts on a managed page throws one of two exceptions - facebook-fql

I am using the RestFB client to fetch all post_ids of a Facebook Page.
The query is
select post_id from stream where source_id=265813166783408
Where the id if of the page I'm querying. It can be found here
I initially tried executing this without an access token. This gives a 104: Requires valid signature error from Facebook.
I looked up this error and the solution that many gave on SO is to use an access token. However if I try with an accessToken (with permissions: manage_pages, publish_stream, read_stream, offline_access, read_insights) then Facebook gives a different error 190: Impersonated access tokens can only be used with the Graph API.
Does this mean I shouldn't use FQL for getting page posts. The Facebook documentation doesn't mention anything on these lines but like I said it keeps alternating between these two errors.
PS: I can use the Graph API with my access token to fetch Posts but for my specific scenario I felt FQL would be a far better option, since I can nest this query into a query on the comments table (eventual aim).
Thank you.
UPDATE:
Please see Facebook developers for a discussion on this particular issue If you are using the RestFB library then also see the relevant issue

We encountered the same problem and found it to be an issue with using fbclient library and a page access token. We switched to calling the API directly (with the Apache HttpClient) and our FQL ran fine with the page access tokens.

Related

Facebook Graph API - User doesn't have enough permissions to load insights

I'm seeing this error for a page with this endpoint:
12345566/feed?fields=insights.metric(post_impressions_unique,post_impressions)
and I'm seeing this error: User doesn't have enough permissions to load insights
I've added the following permissions: read_insights pages_read_engagement, etc that is required according to the docs here but when I contact Facebook Developer support they say I have to add it at to Granular Scope.... how do I do this? I've attached a picture showing what the token debugger shoes for this Page Access Token permissions
I did have a similar issue on some of my pages. I did reach the Facebook's support on the matter.
TL;DR use /published_posts instead of /feed
Facebook's support full reply:
I have investigated this and I have a solution for you. Instead of using the /feed endpoint for the Page, please use the /published_posts endpoint instead.
The 'feed' for a page includes posts made by other Users/Pages when they tag your Page. When you try to access the insights for these posts made by other accounts, we run into the issue that this access token does not have the permissions to view those insights.
The 'published_posts' endpoint only includes posts made by the page itself, so you will be able to retrieve the insights using this.
Thank you for flagging this to us. I will see if there are improvements that could be made to our documentation or error messaging to improve the experience of other developers.

Is it possible to get reviews made by a user on Facebook via Graph API / FQL?

Despite all my research, I can't find a way to get this data via Graph API.
It seems that no permission matches with this...
Any idea ?
https://developers.facebook.com/docs/graph-api/reference/v2.2/page/ratings
Keep in mind that you need a Page Access Token for this, so you must be Admin of the Page. No extra permission needed, just manage_pages to get the Page Access Token, of course.
Getting the ratings for a specific User without accessing a Page is not possible afaik.

Open Graph insights for specific post

We have a Facebook Application with custom Open Graph objects and actions.
We then use a App Access Token to post stories for a particular user from our backend with the normal Open Graph REST API. After the post-call succeeds we log the returned "id" of that post.
Now we would like to collect insight data (e.g. post_impressions_unique) for some of these individual posts/stories using the logged id's.
According to https://developers.facebook.com/blog/post/573/ we should be able to do something like:
https://graph.facebook.com/[POST ID]/insights
Even though this call seems to work using our normal App Access Token, no insight data is returned for the post/story.
Does anyone know if this is possible and how to do it?
We have been experimenting with a normal User Access Token and the "read_insights" permissions, but with no luck. I have read some similar questions but mainly regarding page-posts (this is an App Open Graph post/story).
EDIT:
The facebook article above only refers to "Page" posts. I'm looking for analytics on individual Facebook App Opengraph Posts/stories. It seems difficult to find any good information about this, has nobody attempted this with any success?
You must add insights into a permissions/Extended permissions
Article :
Getting Page Insights
In order to obtain Page Insights via the Graph API, you must use a Page access token, and you must have the read_insights permission. Click on the link below to see this working in the Graph API Explorer.

Using FQL to query insights and likes for Facebook Pages

We run some facebook pages for our clients and we'd like to run off some reports, like many people LIKED those pages yesterday, for example.
I can see that this can be done by FQL, but you need an access_token to run the queries using Facebook Graph API in (C#).
For these Facebook pages there isn't an app associated with them, so without app_id how can I get authenticated to be able to run those queries ?
Thanks
You could create an app that you then use to retrieve the stats.
If you then get an access token for a user that is an admin of the pages and request the read_insight extended permission you can get the insights data for each page, which will give you plenty of stats to report in a handy JSON format.
See here for more details on the insights in the graph API
http://developers.facebook.com/docs/reference/api/insights/

Facebook Graph Api json missing posts

I am developing an web app, which connect to facebook, to get posts, and other stuff liked by users. I have problem with getting all posts from user page using news feed(home connection of Grap API).
When getting access token in my app for user, I ask for read_stream, user_activities and offline access permissions. Then, when I use that token, to get json feed for
https://graph.facebook.com/me/home/?access_token=<retrived_access_token>
some posts(which are show on user page) are missing. I found that posts of my friends, which can be seen only by their friends, are not shown in that feed. The same issue is with posts of users which current I am subscribing.
I was searching on that for a while, and I found, that when I use link from http://developers.facebook.com/docs/reference/api/ to get my news feed, there are much more posts. It's seems to use a token generated for test console app for facebook api.
Then I tried to generate access token which would give me similar results using http://developers.facebook.com/tools/explorer?method=GET. But even when I give to generated token all possible permissions I could not get it working good, there were still some missing posts.
I read answer in that post, Facebook graph API does not return all posts for user, which suggested, that this is because of permissions set by my people who publish posts, who don't want their data to be retrieved by an app. I run some quick test, and I found that changing that setting is working( when somebody change that setting her posts will disappear from both feeds - that using my app token for user, and that under link on api reference page), but it's not the case.
It seems that this token generated on api reference page have an special permission.
I really need to get as much posts from user page as possible. I know that I will not get those blocked by their author, but as many of my users subscribe other users I really need to get access to kind of posts shown on user page.
I also read Facebook graph API: feeds missing in json response but it was also not helpfull.
I will really appreciate any help.
It is impossible to get a full list of posts from the feed / home Graph API, but you can use FQL to query the stream table to get almost every post made by friends, here is a quick example of how you would do that with the javascript sdk:
var query = 'SELECT post_id FROM stream WHERE filter_key = "others"';
FB.api('fql', {'q': query}, function(posts) { console.log(posts.data); });
This will get you the post ids, which you can then use with graph api to fetch the rest of the post info. Or you can get the full list of fields here, you can't select * in FQL so you'll have to list each piece you want and then get comments and likes and names separately.
There is an assigned/medium bug on this at http://developers.facebook.com/bugs/228057243915183. You can bump up the priority by subscribing and indicating you can reproduce it.
Also see http://developers.facebook.com/bugs/231621496918030 where Facebook has said "the stream table and me/graph have limitations. See the documentation for more info. We're trying to make this more clear in the future." Personally I don't think there is really any more info in the documentation though.