Facebook Graph API not working anymore. No changes made - facebook-graph-api

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.

Related

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.

How to retrieve a facebook photo of a different user, is this possible?

I'm trying to retrieve a photo of a user different from the logged one, here what I did:
I have 2 different users that granted "user_photos" permission to my app
I'm able to retrieve the photos uploaded by USER_1 through the API
https://graph.facebook.com/v2.5/me/photos/uploaded?access_token=USER_1_TOKEN
Let's suppose I'm interested in the photo with id PHOTO_ID_123 (privacy public) and I want USER_2 to be able to view that photo. I should call the following API:
https://graph.facebook.com/v2.5/PHOTO_ID_123?access_token=USER_2_TOKEN
(note the different token user in the latter call)
The issue is that now I'm getting the following error from FB:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "GmYciGz/Mpd"
}
}
These two users are mutual friends on facebook, but since the photo is public I expect to be accessible even in case the two users are not mutual friends.
Of course the following API call
https://graph.facebook.com/v2.5/PHOTO_ID_123?access_token=USER_1_TOKEN
is working as expected (it does return photo related data). If USER_2 try to access PHOTO_ID_123 from browser (inside facebook website), he can see the photo.
What am I missing? Is this even possible? To me it seems possible from fb doc: https://developers.facebook.com/docs/graph-api/reference/photo/
Permissions
Any valid access token can read photos on a public Page. A page access
token can read all photos posted to or posted by that Page. A user
access token can read any photo your application created on behalf of
that user. A user's photos can be read if the owner has granted the
user_photos or user_posts permission. A user access token may read a
photo that user is tagged in if they have granted the user_photos or
user_posts permission. However, in some cases the photo's owner's
privacy settings may not allow your application to access it.
Thanks
If i authorize an App with user_photos, i would not want any other App User to be able to see my photos - at least not without my permission per photo. So it does make sense not to be able to access photos of one user with the Token of another.
You could let the User select some photos and store it on your server if you want that to happen. Just because something is public on facebook.com does not mean you can grab it with the API, that would make a lot of permissions pointless.

Unable to retrieve data from facebook graph url for a page

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.

Do Facebook provide the access token (at that instant) or one can get only after the friend's permission? (Using PHP Facebook-graph-API )

I am using PHP for accessing Facebook friends location. I want to access location of all friends. I read that it requires "access tokens" to get client's public information from here
https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens
and here
https://www.sammyk.me/access-token-handling-best-practices-in-facebook-php-sdk-v4
Is that token will be provided by Facebook at that instant of time or my app needs to wait till friend's approval.
I saw this post on stack overflow: How to get user access token?
But i still i can't figure out what if friend is offline. How that token will be passed to my application?
Or is it like that "Tokens are generated by Facebook at time when my application made the request but i can only access the user information later using the same token if he has given permission (when he gets logged in)".?
I am unable to find any explanation regarding this.
Thanks.
You canĀ“t get the location of friends at all. Friend permissions have been removed for privacy reasons, you can only get data of users who authorized your App too. Check out the changelog for more information: https://developers.facebook.com/docs/apps/changelog
That being said, there are different Access Tokens. You can get an App Token without authorization, but you need to implement an authorization process for User or Page Tokens.
More information:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/

Facebook Access to users photos using my app token

Having problems gaining access to a users photo's from my Facebook app.
I request the apps token at runtime using: (replacing the values in [] brackets with actual values.
https://graph.facebook.com/oauth/access_token?client_id=[clientid]&client_secret=[clientsecret]&grant_type=client_credentials
I then try to access a users photo using that access token, ie:
https://graph.facebook.com/fql?q=SELECT pid, src_big, src_small FROM photo WHERE pid IN('4313357036026642248','4313357036026642249','4313357036026642250','4313357036026642251','4313357036026642252','4313357036026642253','4313357036026642254')
The user has authenticated themselves with my app and accepted the USER_PHOTO permissions.
However I get 0 results back. I do get results back when I use that users access token rather than the app token.
I have proven this issue on the graph explorer:
https://developers.facebook.com/tools/explorer?method=GET&path=1004281695
Anyone got any ideas why an app that has been granted access to a user photos cannot get those photos using the app access token ?
Thanks in advance, Rhys
Because with very few exceptions, you can only access a user's data using a valid access token for that user (or one of their friends, depending on the privacy of the object in question).
In this case, use the user's access token, the app access token is for acting on behalf of the app and shouldn't really be used for user-specific calls, as it won't be able to see non-public information except with very limited circumstances