App Access Token can't retrive user public data - facebook

In Graph API, if i make a request using a token generated by Graph API Explorer for the following query:
https://graph.facebook.com/v2.2/993673107328394
I get some results:
{
"id": "993673107328394",
"first_name": "Johann",
"last_name": "Gomes",
"link": "https://www.facebook.com/app_scoped_user_id/993673107328394/",
"name": "Johann Gomes",
"updated_time": "2015-01-19T16:00:34+0000"
}
But, when i use an App Access token, an exception is returned to me :
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
This is very strange because the only difference between user and app access tokens seems to be its valid time of use. Any ideas?
Thanks in advance!

It's all in the docs:
https://developers.facebook.com/docs/graph-api/reference/v2.2/user#readperms
There are a number of fields called the public profile which are with public_profile permission.
Fields that aren't part of the public profile must be be requested with an access token with the relevant 'Extended Profile' permissions.
The first bullet point indicates that you have to use a user access token.

Related

API Graph Facebook - Creation page User TEST

I'm trying to use the Graph api to create pages. So I have an application type Entreprise, and a Test User. I tried this:
Post request to [userTest_id]/accounts/
Params:
{
"name": "Test Page One",
"about": "This is the first page created to check the api",
"cover_photo": {
"url": "https://i.etsystatic.com/6293506/r/il/ea9cf8/1809124703/il_fullxfull.1809124703_swn3.jpg"
},
"picture": "https://i.etsystatic.com/6293506/r/il/ea9cf8/1809124703/il_fullxfull.1809124703_swn3.jpg",
"category_list": "[\"174177802634376\"]"
}
I use user token
I get this error:
{
"error": {
"message": "Unsupported post request. Object with ID '[userTest_id]' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "ATSiLLBx2O1yOuPRFxq4r4V"
}
}
I've followed this doc:
https://developers.facebook.com/docs/graph-api/reference/user/accounts/#Creating
What I'm missing plz ?
Thanks.
Facebook API doesn't allow creating Pages in the "real world" scope. You may do it for test users (created on the Role tab) or, in production, you have to get special approval from Facebook (not just permission).

getting error on facebook catalog batch api on using app token

api works for user token but does not when i put app token
https://graph.facebook.com/v9.0/<my-catalog-id>/batch?access_token=<my-app-token>&requests=[{"method": "UPDATE","retailer_id": "retailer-id","data":{"availability": "in stock", "price": "10", "currency": "USD"}}]
{
"error": {
"message": "Unsupported post request. Object with ID '********' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33
}
}
If the id in ****** is your catalog id then your app must be missing permission. To access catalog, your app should have catalog_management and ads_management permissions. For better understanding you can refer this url. This document has example of real estate listings.
If the id in ****** is your catalog id then your app must be missing permission. To access catalog, your app should have catalog_management and ads_management permissions. For better understanding you can refer this url. This document has example of real estate listings.

App access token, can't get user information

When I try to use the already generated access token, on this https://graph.facebook.com/4921782178422?fields=id&access_token=ACCESS_TOKEN, it gives me this in response:
{
"error": {
"message": "Unsupported get request. Object with ID '4921782178422' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "F2ot2MGcBBM"
}
}
Facebook writes that all access tokens have permissions to public_profile, but i can't use the link above.
4921782178422 is a user id.
It works fine, when I use my own user access token, but that's only valid for 1 hour, and I need it longer than that.
I have followed these steps:
facebook: permanent Page Access Token?
What do I do wrong?

Facebook Open Graph event search

On Graph API Explorer I can do this search: search?q=Barcelona&type=event
But when I try the same with my app access token I get this error:
{
"error": {
"message": "(#200) Must have a valid access_token to access this endpoint",
"type": "OAuthException",
"code": 200
}
}
The other searches work well.
UPDATE 2017-11-27:
As Facebook doesn't allow an event search based on location anymore, I'd recommend to use https://github.com/tobilg/facebook-events-by-location-core
Original answer:
Please refer to https://developers.facebook.com/docs/reference/api/search/#access_tokens
There, it's stated that all searches except for pages and places require an user access token.

Can't get Facebook user id by Graph

I'm working on an iOS app and noticed that one user is not loaded when I do a requestForMyFriends.
After looking more into this it seems that the Graph API explorer also doesn't return anything for the particular Facebook user. It's a user and not a Fanpage or something.
So:
I've the page for example (which when I enter In my browser will bring up the Page nicely): https://www.facebook.com/user-name
https://graph.facebook.com/https://www.facebook.com/user-name
Will return:
{
id: "https://www.facebook.com/user-name"
}
https://graph.facebook.com/user-name
Will return:
{
error: {
message: "Unsupported get request.",
type: "GraphMethodException",
code: 100
}
}
http://findmyfacebookid.com/ wil return nothing.
The graph API will return:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
I'm trying to reproduce this with my test Facebook account and put all restrictions to the max but I always get a nice result with a FacebookId.
My question:
What settings do I need to change to my test Facebook account to reproduce this problem?
"Unsupported GET Request" covers many situations, but at the root the message means you tried to request something via the API which is not available to you via the API
For a request which attempts to retrieve data about a known username or user ID the most likely reasons are:
User has blocked your app
User has disabled all platform apps in their privacy settings
User has deactivated their account
User has deleted their account
if i had to bet, I'd say it's the second one in this case
The problem is the parameter, you don't have to pass in the whole URL of a profile, just the username/profile-id.
For example: we want to get the info of Mark Zuckerberg. His Facebook username is zuck. The URL would be https://graph.facebook.com/zuck and will return the following output
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "http://www.facebook.com/zuck",
"username": "zuck",
"gender": "male",
"locale": "en_US"
}
Using https://graph.facebook.com/4 (4 is the profile id of Mark Zuckerberg) would produce the same output.
Edit
After some further investigation it turned out that said user might have deactivated her account and that is why you see this error. I have used a testuser of one of my apps, went to Settings -> Security -> Deactivate my account and taxa, every request to the Graph API returned the result you're seeing.