Facebook API: How to get the FB login user's unique ID? ID from API doesn't match 'real' user ID in v2.0

facebook-graph-api, facebook-graph-api-v2.0, facebook-login, ios

Solution

Since v2.0 of the Facebook API the user IDs returned to your app are scoped to your app (i.e each app receives a different identifier for any given user) - you can't compare what that site is telling you to what your app received when you called `user.objectID` because they're intentionally different strings

Use the ID returned to your app as the identifier for users in your app - there's no need to try and find the 'real' or 'old' user ID - there's no reason for you to need to use the user ID given to any other app ID

There's more information about that the changes from v1.0 to v2.0 here: https://developers.facebook.com/docs/apps/upgrading

And the app-scoped IDs are specifically discussed here, including a way for developers with multiple apps to corelate the IDs for users who use more than one of their apps : https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids

Problem

``` - (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user { self.profilePictureView.profileID = user.objectID; self.nameLabel.text = user.name; NSLog(@"My ID:%@", user.objectID); } ``` I have tried to print the user id using the above code. And what I get is `3176144783XXXXX`. However, I got a different one using this online tool http://findmyfacebookid.com/. The result is `1000042591XXXXX`. Does anyone know the difference? Why do my app and 'findmyfacebookid.com' receive a different user ID for the same user? Note: My mobile app need to use the FB unique ID to create my own user database. So this is the reason I need a unique ID.

Original source

Related problems