If you have a Facebook, for instance Zuckerbergs user id '4', or username, 'zuck', how do you get the new app-scoped id with Graph v2.0
using the app's access token? Can't seem to find anything about this in the docs.
(To get a scoped User ID for a Page, your app must query the endpoint using that Page's access token.) Your appsecret_proof hash. Refer to our Facebook Login Security guide for more information.
User ID. Your User ID is a string of numbers that doesn't personally identify you but does connect to your Facebook profile. You have a User ID automatically, whether or not you choose to create a username. Learn how to find your user ID.
Those of you who use the Facebook Graph API know that there were some big changes with the release of version 2.0. One of the biggest? Instead of returning a user's Facebook ID, the API is now returning an app_scoped_user_id, a unique identifier to each app/user combo.
This is basically the answer given to the other-way-around question, Get Facebook User ID from app-scoped User ID .
Basically, easiest straight forward flow is a call to https://graph.facebook.com/?ids=http://facebook.com/[FBID/USERNAME]&access_token=[APP_ID]|[APP_SECRET]
Doing that for Zuckerberg, will give you the familiar
{
"http://facebook.com/4":
{
"id": "4",
"first_name": "Mark",
"gender": "male",
"last_name": "Zuckerberg",
"link": "https://www.facebook.com/zuck",
"locale": "en_US",
"name": "Mark Zuckerberg",
"username": "zuck"
}
}
But, if that user had only logged in to your app for the first time after 30th May 2014 (the changeover date), he'd have something like...
{
"http://facebook.com/4":
{
"id": "277123456789101",
"first_name": "Mark",
"gender": "male",
"last_name": "Zuckerberg",
"link": "https://www.facebook.com/zuck",
"locale": "en_US",
"name": "Mark Zuckerberg",
"username": "zuck"
}
}
Giving you the 277... app-scoped id for your app.
In addition to the comment by @Raymond Yee, you have to provide APP_ID
, APP_SECRET
and FACEBOOK_USER_ID
(note that this is the numeric id, not the username):
So it works with this URL:
https://graph.facebook.com/v2.3?access_token=[APP_ID]%7C[APP_SECRET]&ids=[FACEBOOK_USER_ID]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With