7
- (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.

Kubba
  • 3,390
  • 19
  • 34
Zidong
  • 121
  • 1
  • 3
  • 7

1 Answers1

25

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

Igy
  • 43,710
  • 8
  • 89
  • 115
  • Is it never change in case user login/logout/change password, change user info,.... ? – Shinichi Jun 08 '16 at 00:39
  • The ID is for the `` pair - there's no session info used to generate it (unlike access tokens) – Igy Jun 09 '16 at 11:07
  • 1
    What if I want to utilize the users registered in my other application into this application so they don't have to register twice? I am trying to implement my own "Login with " and really need this. – Muhammad Qasim Aug 18 '16 at 05:21
  • You'll need to use something like the [Business Mapping API](https://developers.facebook.com/docs/apps/for-business) to correlate the user in one of your apps to their profile from another of your apps, but the user would need to log into each app separately – Igy Aug 19 '16 at 13:51
  • Hello @Igy, I have an fb app from old days, I have real user id and wants to convert to app scoped user id once the user login as similar mentioned [here](https://stackoverflow.com/a/29154912/492258). Is there any way to achieve this? Tnx – asdf_enel_hak Oct 17 '18 at 10:12
  • Why would you want to change the identifier? Your app should still be able to use the old, 'real' ID – Igy Oct 17 '18 at 11:09
  • @Igy When but user authenticate I should match them. At the moment I can not figure out how to that? – asdf_enel_hak Oct 17 '18 at 12:27
  • What are you trying to match them to? The same app ID should always receive the same user ID for a given user when they log in. If you're trying to correlate the ID your app receives, to one you collected elsewhere, it's not supposed to be possible, that's the entire reason app-scoped IDs exist – Igy Oct 21 '18 at 07:02