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

查看:23
本文介绍了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.

推荐答案

自 Facebook API v2.0 起,返回到您的应用的用户 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 的方法:https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids

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 与 v2.0 中的“真实"用户 ID 不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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