Facebook API:如何获取FB登录用户的唯一ID?来自API的ID不匹配'真实' v2.0中的用户ID [英] Facebook API: How to get the FB login user's unique ID? ID from API doesn't match 'real' user ID in v2.0

查看:206
本文介绍了Facebook API:如何获取FB登录用户的唯一ID?来自API的ID不匹配'真实' v2.0中的用户ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我尝试使用上述代码打印用户ID.而我得到的是3176144783XXXXX.

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

但是,我使用此在线工具 http://findmyfacebookid.com/换了另一种工具.结果为1000042591XXXXX.

However, I got a different one using this online tool http://findmyfacebookid.com/. The result is 1000042591XXXXX.

有人知道其中的区别吗?为什么我的应用程序和"findmyfacebookid.com"为同一用户收到不同的用户ID?

Does anyone know the difference? Why do my app and 'findmyfacebookid.com' receive a different user ID for the same user?

注意:我的移动应用程序需要使用FB唯一ID来创建自己的用户数据库.所以这就是我需要唯一ID的原因.

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.

推荐答案

自v2.0版的Facebook API以来,返回给您应用的用户ID的范围仅限于您的应用(即,每个应用为每个给定的用户接收一个不同的标识符) -您无法将网站告诉您的内容与调用user.objectID时应用程序收到的内容进行比较,因为它们是故意不同的字符串

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

使用返回给您应用的ID作为应用中用户的标识符-无需尝试查找真实"或旧"用户ID-无需使用给定的用户ID到其他任何应用程序ID

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

有关从v1.0到v2.0的更改的更多信息,请参见: https://developers.facebook. com/docs/apps/升级

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

这里将详细讨论应用程序范围的ID,其中包括使用多个应用程序的开发人员为使用多个应用程序的用户提供ID核心的方法:

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

这篇关于Facebook API:如何获取FB登录用户的唯一ID?来自API的ID不匹配&amp;#39;真实&amp;#39; v2.0中的用户ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆