Can't get public info using Facebook Graph - facebook

I'm trying to get public profile using user_token. I registered FB app and get user_token from page: https://developers.facebook.com/tools/access_token/
but when I try to get public profile https://graph.facebook.com/100000378611443?limit=1000&access_token={user_token}
I see an error:
{
"error": {
"message": "The global ID 100000378611443 is not allowed. Please use the application specific ID instead.",
"type": "OAuthException",
"code": 2500
}
}
But if I use user_token in above URL from another my app I can successfully get public user profile.
What am I doing wrong?
Thanks.

Since v2.0 of Facebook API apps are no longer allowed to use global IDs, just app-scoped ID. These ID are generated when a user logs in onto your application.
If you are attempting to retrieve current logged in user's information, you should use /me endpoint along with the user's access token: https://graph.facebook.com/me?access_token={user_token}
Note that with these new scoped IDs, apps are not allowed to retrieve any data from users who haven't gave permissions to the app.
Cheers

You can still use the older version of Facebook Graph API V1.0 which will continue to exist until April 30th, 2015.
https://graph.facebook.com/v1.0/100000378611443

You must use access token, not user token! You can obtain one from Graph API Explorer here https://developers.facebook.com/tools/explorer
Then you must have at least user_about_me permission to get profile data. As many user data permissions you have, as many endpoints and data you obtain. Keep in mind, access token you get from Graph API Explorer is short living - expires in an hour or so. More about tokens and their terms here: https://developers.facebook.com/docs/facebook-login/access-tokens

Happens to me too, trying to using "Graph Api Explorer" with an user id obtained debugging my application.
User id that obtain from a call as:
../<event_id>/likes
isn't REAL user id, but a kind of id "encrypted" (let me use the word) with access_token.
So if you wanna test that user id on GAE, you need to specify also access token:
https://graph.facebook.com/<user_id>?access_token=<application_access_token>

Related

Is it posible to use facebook graph api to list a page feed without authorizing APP

I want to access next
graph.facebook.com/pagename/feed/
but I don't want the app to ask the users for permissions, since this information is public available. Is it somehow posible? Until now what I get is:
fbtrace_id
"G69vv730PRn"
message
"(#200) The user hasn't authorized the application to perform this action"
type
"OAuthException"
With an access token generated by explorer.
What I want to do is next:
A user input the page name or id, retrieve last posts, and then for each post retrieve likes and comments.
I mean can't I do something like:
http://graph.facebook.com/v2.7/pagename
and get page information?

Get name and photo from v2.0 app scoped Facebook id, without an access token

Is it possible to get name and photo from v2.0 app scoped Facebook id, without an access token?
This used to be possible in v1.0 (with original Facebook ids), see the link.
But in v2.0 with app scoped ids, I get this error:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
This seems to me to be a common use case, where in a game, playerA is logged into Facebook and playerB is not using Facebook, and you want playerB to be able to obtain playerA's Facebook name and photo, without logging in.
That's intentional - in v2.0 no API calls can be made without an access token except the call to retrieve a user's profile picture
You should store the name in your own database, and retrieve the photo using the app scoped ID - since you'll already be deciding which users to show based on your own database you should already have both pieces of information in your system and not need to fetch anything from Facebook's API without an access token

The global ID is not allowed. Please use the application specific ID instead

In Graph API 2.0
When I using new graph api to access my friends information, I got the message below.
Here, xxx is an user id.
{
"error": {
"message": "The global ID xxx is not allowed. Please use the application specific ID instead.",
"type": "OAuthException",
"code": 2500
}
}
What's application specific ID?
At least, there's nothing in the docs about that.
(If I use Graph API 1.0, everything will be fine.)
Here's an excerpt from a blog post I wrote on this topic that answers your question:
In the simpler days of v1.0, when the Graph API reported on a user, the id value it provided was a global id number for that Facebook user. These values were “global” in the sense that they could be shared between client applications. In v2.0, all user data provided by the /user endpoint and its children use application-specific ids. These ids are a unique identifier not just of the Facebook user, but of the client-user pair. This mean that you can’t share user ids between applications. (Though Facebook does provide an API for mapping between applications that are part of single organization.)
An important consequence of this fact is that the user ids recognized by the Facebook applications you use for development will not match the ones your production app recognizes. So, if you store your users’ Facebook ids in your database in production, you won’t be able to match up users in that database with data returned from the API in development. That’s annoying!
And there’s no way around it. You’ll just have to query for a few of your friends from the development app and manually overwrite their stored Facebook ids in your development database. This will give you a few exemplars to develop against.
To stop easily this issue, I just added "version : 'v1.0' " in my FB.init like this:
window.fbAsyncInit = function() {
FB.init({
appId: '*****',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v1.0' // use version 2.0
});
};
Of course this is temporary and need to look through the different documentations as suggested by Asymmetric
For apps using API version 2.0 - you can only use the App-Scoped-ID to access data about a user on v2.0+
If you're an existing app upgrading some calls from v1.0 to v2.0 you can continue to use the user IDs you received for your app's users - for non-users of your app you must use the app-scoped ID if you want to access their data, and make the call from the same app which was given that ID
There's more information about how App Scoped IDs work here: https://developers.facebook.com/docs/apps/changelog#v2_0_graph_api
It's because you are using the app access token instead of user access token
Try the user token from this page:
If that works you need to think about getting the user access token from your app. You can give the user a prompt and receive a code as a parameter on the redirect_uri parameter
https://www.facebook.com/dialog/oauth?client_id={app-id}&redirect_uri={redirect-uri}
After you receive that code you redeem it for a user access token with a request like this:
GET https://graph.facebook.com/oauth/access_token?client_id={app-id}&redirect_uri={redirect-uri}&client_secret={app-secret}&code={code-parameter}
Global ID is your user ID, application specific ID is ID you are able to access (nobody knows)! This message means that Facebook doesn't authenticate your application with permission to access your profile! In other words, you need to provide access token for your user, giving the application appropriate permissions to access your data. You can obtain manually short-term access token from Graph API Exlorer here https://developers.facebook.com/tools/explorer
To access your friends info, you must give user_friends permission. More about access tokens and their life is here: https://developers.facebook.com/docs/facebook-login/access-tokens

Are non-app users' pictures still avalible in Facebook Open Graph v2.0?

In Graph API v1.0, I could get the profile picture of any user with the following call graph.facebook.com/{uid}/picture (fb doc).
In Graph API v2.0 facebook says it will return (a) app-scoped user ids for app users, and (b) temporary tokens for non-app users (through /me/taggable_friends and /me/invitable_friends api calls). Based on this, I would assume that the picture api call is deprecated in v2.0. However, the documentation makes it seem like there was not change to this call in v2.0.
Anybody knows if (full-size) public profile pictures of non-app users will be available in v2.0?
It is still possible to get a person's profile picture in v2.0.
http://graph.facebook.com/v2.0/APP_SCOPED_ID/picture will redirect to a picture of the user represented by that app-scoped ID.
If a user previously logged into your app when your app was coded against v1.0, they may still be known to your app by their original Facebook user ID. For this reason, http://graph.facebook.com/v2.0/ORIGINAL_USER_ID/picture will also still work.
/<user id>/picture does not require an access token in V2.0 and will work even when <user id> is an app scoped ID
The ID provided needs to be the user's actual ID or an app scoped IDthe response from /<user id>/invitable_friends or /<user_id>/taggable_friends won't work in the same way
Both of those APIs will also return you the full URL of the invitable or taggable user's photo
as part of the response, though.
It does work fine with original user IDs. For app-scoped IDs I haven't figured out how to use them.
While http://graph.facebook.com/v2.0/APP_SCOPED_ID/picture is supposed to work with the new app-scoped IDs, I can only get this response:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
Note that this response is different from the response for completely invalid IDs. If you use an invalid user ID, you would get:
{
"error": {
"message": "(#100) No node specified",
"type": "OAuthException",
"code": 100
}
}
EDIT: As of May 10, 2014 this is a known bug.
The Graph API request that is currently working is
http://graph.facebook.com/v2.0/APP_SCOPED_ID?fields=picture

How to Get feed of public Facebook page using Graph api?

There are already several questions on StackOverflow ( Can you get a public Facebook page's feed using Graph API without asking a user to allow? Get public page statuses using Facebook Graph API without Access Token? )concerning my question: I need to get through the graph API the feeds of a public page on facebook.
I followed the instructions but I always get:
{"Error": {"message": "An access token is required to request this resource.", "Type": "OAuthException", "code": 104}}
how can I fix this? I'm going crazy because everyone seems to work except me! thanks
Based on your description, the error is that you weren't supplying a valid access token with your request.
If the app's type is set to 'Native / Desktop' it's assumed you distributed the app's secret key with the binary, and thus the app access token isn't trusted (and 'getAccessToken' in the PHP SDK will only work when real users log in, it can't fall back to the app token)
If you were attempting to use the app access token to read the page's feed, this would fail in the manner you described.