Facebook API: how to get unique FB login user id? The ID from the API does not match the "real" user ID in version 2.0

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user { self.profilePictureView.profileID = user.objectID; self.nameLabel.text = user.name; NSLog(@"My ID:%@", user.objectID); } 

I tried to print the user id using the above code. And I get 3176144783XXXXX .

However, I have another using this online tool http://findmyfacebookid.com/ . The result is 1000042591XXXXX .

Does anyone know the difference? Why does my application and "findmyfacebookid.com" get a different user ID for the same user?

Note. My mobile application needs to use a unique FB identifier to create my own user database. This is why I need a unique identifier.

+7
ios facebook-graph-api facebook-login
source share
1 answer

Since Facebook API v2.0, the user IDs returned to your application are tied to your application (i.e. each application receives a different identifier for any given user) - you cannot compare what this site tells you about your application received when you called user.objectID because these are intentionally different lines

Use the identifier returned to your application as the identifier for users in your application, there is no need to try to find the "real" or "old" user identifier - there is no reason to use the user identifier for any other application identifier

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

And extended-scope application identifiers are discussed here, including a way for developers with multiple applications to combine identifiers for users who use more than one of their applications: https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids

+25
source share

All Articles