Facebook API-每个应用程序都有不同的用户ID? [英] Facebook API - different user ID's for each app?

查看:445
本文介绍了Facebook API-每个应用程序都有不同的用户ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发移动应用程序,因此,我需要为此专门设计一个新应用程序.看来,愚蠢的事情是Facebook决定为每个应用程序使用不同的用户ID".除了看不到这一点之外,我困惑于如何为给定用户提取相同的 userId ,以使其与数据库匹配.我正在使用 oauth.io 处理登录并返回值:

I'm currently working on a mobile app, and as such I need to have a new app specifically for this purpose. The stupid thing it seems, is that Facebook have decided to use different "user ids" for each app. Apart from not seeing the point in this what-so-ever, I'm baffled as to how I can extract the same userId for a given user, to match it up with my DB. I'm using oauth.io to process the login, and return the values:

$('#facebook-login').click(function() {
    $('#ajax_spinner_wrapper').show();
    OAuth.initialize('CmRGYdnRMWM2ZrOb7M1Nf1_T57o');
    OAuth.popup('facebook').done(function(result) {
        //console.log(result)
        result.get('/me').done(function(data) {
            //todo with data
            console.log(data);

            $.post('https://steampunkjunkies.net/cgi-bin/mobi_login.cgi', { action: 'store_session', what: 'facebook', user: data.id }, function(result) {
                $('#ajax_spinner_wrapper').hide();
            });
        }).fail(function(err) {
            //todo with err
            console.log("Hit an error?");
        });


    })
    .fail(function (err) {
        alert("oops, we got an error!");
        console.log(err);
        $('#ajax_spinner_wrapper').hide();
    });

    return false;
});

问题是,它给我每个应用程序完全不同的ID.这是基于Web的内容:

The problem though, is that it gives me totally different Id's in each app. Here is what I get with my web-based one:

'id' => '838605583',

..,然后在我的oauth.io( https://oauth.io )设置中使用其他应用:

..and then using the other app in my oauth.io (https://oauth.io) setup:

id  "10155167132970584"

两个用户完全相同.

是否有某种关联这些ID的方法,所以我可以将它们匹配在一起?令人惊讶的是,Facebook认为这样的事情不会成为问题!

Is there some way to correlate these Id's, so I can match them together? Its amazing that Facebook didn't think that something like this would be an issue!

注意:来自Facebook的有关此更改的一些信息:

NOTE: A bit of info from Facebook, regarding this change:

https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids

当人们首次登录使用API​​ v2.0编码的应用程序实例时,Facebook将开始发布应用程序范围的用户ID.使用应用程序范围的ID,同一用户的ID在应用程序之间将是不同的.

Facebook will begin to issue app-scoped user IDs when people first log into an instance of your app coded against v2.0 of the API. With app-scoped IDs, the ID for the same user will be different between apps.

无论最初使用哪种版本来注册您的应用,对于已经登录您的应用的用户,ID都将保持不变.对于过去在任何时候登录您的应用程序的任何人,此更改都向后兼容.

No matter what version they originally used to sign up for your app, the ID will remain the same for people who have already logged into your app. This change is backwards-compatible for anyone who has logged into your app at any point in the past.

如果您不跨应用映射ID,则无需更改任何代码.如果您需要在多个应用程序中映射相同的用户ID或进行跨应用程序促销,则我们添加了一个称为业务映射API的新API.这使您可以在所有应用程序之间映射已登录用户的ID,只要这些应用程序都属于同一公司即可.了解有关实施交叉促销的更多信息.

If you're not mapping IDs across apps, then no code changes should be required. If you need to map the same user IDs across multiple apps or run cross-app promotions, we've added a new API called the Business Mapping API. This lets you map a logged-in user's IDs across apps as long as those apps are all owned by the same business. Learn more about implementing cross-promotions.

对于尚未登录您的应用程序的用户,用户ID可能会更改,具体取决于您调用的API的版本.在v1.0版的API中,未登录您的应用程序的用户将使用其原始Facebook用户ID进行引用,而在v2.0版中,它们将通过应用程序范围的ID进行引用.

For users who have not logged into your app, the user ID may change depending on the version of the API that you call. In v1.0 of the API users who have not logged into your app will be referred to by their original Facebook user ID, whereas in v2.0 they will be referred to by an app-scoped ID.

我们添加了新的API端点,使您可以标记和邀请不使用您的应用的朋友.这些API返回令牌,这些令牌可用于生成用于标记和邀请的自定义接口.这些令牌并不是可缓存的,我们不保证自收到包含令牌的API响应起24小时内它们将保持稳定.它们既不同于未登录您的应用程序的人在数据上使用的ID,也不同于应用程序范围的ID.

We've added new API endpoints that allow you to tag and invite friends who don't use your app. These APIs return tokens which may be used to generate custom interfaces for tagging and invitations. Those tokens aren't meant to be cachable and we make no guarantees that they will be stable beyond 24 hours from the time the API response containing them was received. They aren't the same as either the IDs used on data for people not logged into your app nor the same as the app-scoped IDs.

用户可以在应用程序的编辑设置"对话框中检查已安装的每个应用程序的应用程序范围ID.确保您的应用程序用户在通过支持查询与您联系时知道如何找到它

Users can check their app-scoped IDs for each app they've installed in the app's Edit Settings dialog. Make sure users of your app know how to find it when they contact you with support queries

我真的不明白他们的逻辑.为每个用户使用唯一的标识符更有意义,该标识符可用于针对任何数量的应用进行验证.以我为例,有人登录了我们基于Web的应用程序,然后他们还想登录到移动应用程序-但是该应用程序具有不同的用户ID,因此无法将2链接在一起!埃格(Eugh)

I really don't get their logic. It makes much more sense having a unique identifier for each user, which can be used to verify it against any number of apps. In my case, someone logs into our web-based app, then they also want to log into the mobile one - but its got a different user ID, so there is no way to link the 2 together! Eugh

推荐答案

嗯,这是很老的消息.自2014年4月30日以来就一直如此.随着图API v2.0的引入,FB还引入了针对您的用例设计的Business Mapping API.

Well, this is very old news. It's been like that since April 30th 2014. With the introduction of the graph API v2.0, FB also introduced the Business Mapping API, which is designed for your use case.

您不会收到一个用户ID,但是会收到token_for_business:

You won't receive one user id, but you'll receive a token_for_business:

这将返回一个字符串,该字符串在同一业务管理器管理的所有应用程序中都与此人相同.

This returns a string which is the same for this person across all the apps managed by the same Business Manager.

请参见

  • https://developers.facebook.com/docs/apps/for-business#field
  • https://developers.facebook.com/docs/apps/for-business#api
  • https://developers.facebook.com/docs/apps/business-manager#create-business

这篇关于Facebook API-每个应用程序都有不同的用户ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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