Unable to retrieve data from facebook graph url for a page - facebook-graph-api

Check out:
https://www.facebook.com/MitraJyothiorg
It is a page of an NGO.
Correspondingly, I should be able to find data of the page in:
http://graph.facebook.com/MitraJyothiorg
This does not seem to work. Any clues?
Please note: I am doing a simple http call and it usually works for other pages, for example, if i do the same thing for another page:teachforindia

The error message is quite clear:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
You need to add at least an App Access Token. See
https://developers.facebook.com/docs/graph-api/reference/page#Reading
For pages that are published, you need:
An app or user access token is needed to view fields from fully public pages.
A user access token is needed to view fields from restricted pages that this person is able to view (such as those restrict to certain demographics like location or age, or those only viewable by Page admins).
A page access token can also be used to view those restricted fields.

I am not able to access that page (get a 404 error). Maybe the page is still hidden? Then you will not be able to access it via the graph API imho.

Related

how to retrieve facebook data from a page that is not mine

I am working on automatic language processing, I want to retrieve data from facebook and build my dataset, the problem is that each time I try to retrieve this data, I encounter this problem:
{
"error": {
"message": "(#100) Page Public Metadata Access requires either app secret proof or an app token",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "Azl7f9Wz5PDpX9K-dDIJ3xm"
}
}
I understand that the problem lies in the app token, but the concern is that I cannot get it and I don't know how to do it, is that possible?
Public meta data access does not cover this, the feed of a page is not meta data. You will have to submit your app for the Page Public Content Access feature.
The Page Public Content Access feature allows read-only access to public data on Pages for which you lack the manage_pages login permission.
Documentation on this can be found by clicking this link.

How to generate correct access token when my app already has Page Public Content Access

Our team is creating an app that analyzes Facebook reviews/recommendations. We have submitted an initial version of the app to FB for approval to use Page Public Content Access (PPCA), and have been approved. However when we started testing it after approval and after going to Live mode, we have not been able to generate any tokens that enable us to access the public content we are looking for.
There was a similar question posted recently, 54943575/facebook-graph-api-review-rating-data-with-page-public-content-access. However the answers that appeared for that one said that you can't access this content without manage_pages permission for each individual page, while the FB documentation clearly says you can do so with the Page Public Content Access: "Allows read-only access to public data on Pages for which you lack the manage_page login permission. Readable data includes business metadata, public comments, posts, and reviews." It is true that you need manage_pages in order to write, e.g. delete or post, content to any pages. The documentation also says that with PPCA permission, an allowed use is "Provide aggregated, anonymized public content for competitive analysis and benchmarking", for which clearly you would not be able to get manage_pages permission for all pages you access.
What this question boils down to is this" is the FB documentation for PPCA correct, and if so, how can we generate the access token(s) needed to use it, now that we have it?
Update: the following graph call (from the FB Graph API SDK for Python) that retrieves "posts" does work:
page_posts = graph.get_connections(id=getpage_id, connection_name='posts')
While the following one that attempts to retrieve reviews/ratings, does not:
page_reviews = graph.get_connections(id=getpage_id, connection_name='ratings')
The latter call produces the error:
(#210) A page access token is required to request this resource.",
"type": "OAuthException",
The Facebook Developers documentation says that the Page Public Content Access applies to ratings as well as posts, but this appears to contradict that, unless we are calling the graph incorrectly here.
You can only get a Page Token of Pages you manage - for other Pages (and Page Public Content Access), you can just use an App Access Token. More information: https://developers.facebook.com/docs/facebook-login/access-tokens/
For ratings/reviews, you MUST use a Page Token. Page Public Content Access only gives you access to the Page feed and photos, for example.

Get comments of public facebook post

I'm trying to download every comment on a public facebook post (it's one of those "can you do this basic algebra problem" posts - I want to see what percent of the comments get it right).
The Graph API Reference shows that I should be able to just GET graph.facebook.com/v2.5/{object-id}/comments.
I believe the object-id of this post is {user-id}_{post-id}, where post-id is the id in the url. So given this url:
https://www.facebook.com/beth.mansfield.9/posts/10207885721596563
The user-id of facebook.com/beth.mansfield.9 is 1101752663 (from findmyfbid.com), and the post-id is 10207885721596563 (from the url), which makes the object-id="1101752663_10207885721596563".
When I try graph.facebook.com/v2.5/1101752663_10207885721596563/comments in the Graph API Explorer, though, I get:
{
"data": [
]
}
What am I doing wrong? Is there another way to get the comments? There are close to a million so loading them all in the browser and scraping with javascript would be unfeasible.
That is a user profile. You can only get data of a user profile if that specific user authorized your App. In that case, you would need to authorize with the user_posts permission. Just because it is public, does not mean you can get the data - that would only work for Pages.

Facebook Graph API not working anymore. No changes made

During the past couple of weeks I've been sporadically downloading posts from a couple of Facebook pages with this call:
https://graph.facebook.com/105317422843784/posts
Everything was working fine and I would get the usual json response of public posts (which doesn't require authentication afaik).
Now I get this:
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104
}
}
I haven't changed anything in my code, and I tested in two different browsers and two different machines with the same result. I don't think I've hit any limits (I'm using the API very seldom). I can't find any changes made to the API either.
Is anybody else having trouble with this? Can anybody point me to a lead?
Taken from the documentation on: https://developers.facebook.com/docs/graph-api/reference/v2.2/page/feed/
An access token is required to view publicly shared posts.
A user access token is required to retrieve posts visible to that person.
A page access token is required to retrieve any other posts.
Looks like you need an access token.
From today, in order to get posts from public pages through Facebook Graph, we always need to use Access Tokens.
New Permissions
An access token is required to view publicly shared posts.
A user access token is required to retrieve posts visible to that person.
A page access token is required to retrieve any other posts.
Old Permissions
An app or user access token is needed to view fields from fully public pages.
A user access token is needed to view fields from restricted pages that this person is able to view (such as those restrict to certain demographics like location or age, or those only viewable by Page admins).
A page access token can also be used to view those restricted fields.
Facebook is going through an entire change with their recent conflicts and allegations. They have stopped all API pulling for now and the access will be given again once all your Facebook Developer apps are reviewed by them.

why does posting to facebook page yield "user hasn't authorized the application"

I have read the fb docs and written code to publish a message to a facebook "page", however I am getting an error that I don't expect to see:
(#200) The user hasn't authorized the application to perform this action
Here's what I've done:
I set up a facebook application, which provides my APP_ID and
APP_SECRET.
I set up a test facebook "page". Let us refer to its fb id as PAGE_ID.
Used OAuth to get a USER_ACCESS_TOKEN with scope "publish_actions,manage_pages" for the user. I accepted the permissions requested by my app when redirected to the facebook auth page.
I did a GET on https://graph.facebook.com/me/accounts using the USER_ACCESS_TOKEN, and I get back a list of pages I administrate, including the one I want to post to.
This block of data for my page looks like:
{
"data": [
{
"category": "Community",
"name": "My Generic Test Page",
"access_token": PAGE_ACCESS_TOKEN,
"id": PAGE_ID,
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
},
....
]
}
Then I use the PAGE_ACCESS_TOKEN to post a message to the page:
I did a POST on https://graph.facebook.com/PAGE_ID/feed with a field message equal to This is a test post.
Facebook returns:
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException",
"code": 200
}
}
Using the token debugger, I can confirm that my PAGE_ACCESS_TOKEN is valid, and has scopes: manage_pages and publish_actions.
Where am I missing authorizing the application? Do I need additional scopes? Did I miss clicking something on the facebook authorization screen? Is there a setting on the app I am missing? After days of debugging this, I must be blind to the problem. :-|
You should add permission called status_update, for example
https://www.facebook.com/dialog/permissions.request?_path=permissions.request&app_id=145634995501895&redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html%3Fdisplay%3Dpage&response_type=token&fbconnect=1&perms=status_update&from_login=1&m_sess=1&rcount=1
and i'm able post to page i liked with the access token i get just now:
If you want to post as the admin of the page, you're require both manage_pages and status_update permissions, for example
https://www.facebook.com/dialog/permissions.request?_path=permissions.request&app_id=145634995501895&redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html%3Fdisplay%3Dpage&response_type=token&fbconnect=1&perms=manage_pages%2Cstatus_update&from_login=1&m_sess=1&rcount=1
Cheers
status_update is not used anymore. To publish on pages, I had to use both manage_pages and publish_pages.
Well, this seems to be a common mistake that most of us make while trying to do an activity in social netwroks. Before trying to put up an open graph action,You need to set the permissions in your initial authorization request . By default you only gain 'read-only' access to their basic information.
Settintg up permisson at teh time of authetication is a must for Facebook and LinkedIn APIs..
See the public_actions section in Facebook open graph permissions here and make relevant changes in the authorization code , and get your issue solved.
I found the best way to get a valid token and check permissions was via the Graph API Explorer BUT while Facebook's documentation is extensive it is not always the easiest to follow.
In the explorer you have to look at both:
The Application Currently at the top and quite subtle, I missed this for ages.
Get Token Dropdown What you click to get a Token, when you click the arrow you can choose pages and other items you have access to for selecting a token for.