I am currently working on a mobile application, and therefore for this I need to have a new application. It seems silly that Facebook decided to use different βuser IDs" for each application. Besides the fact that I donβt see the point in this, I never thought about how I can extract the same userId for this user to map it to my database. I use oauth.io to handle login and return 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; });
The problem is that it gives me completely different identifiers in each application. Here is what I get from my web interface:
'id' => '838605583',
.. and then using another application in my oauth.io command ( https://oauth.io ):
id "10155167132970584"
Both for the same user.
Is there a way to match these identifiers, so I can match them together? Its amazing that Facebook did not think that something like this would be a problem!
NOTE: Some information from Facebook regarding this change:
https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids
Facebook will begin to give out user identifiers with applications when people first enter an instance of your application encoded against the v2.0 API. When using identifiers with applications, the identifier for the same user will differ between applications.
No matter which version they originally used to register your application, the identifier will remain the same for people who are already logged into your application. This change is backward compatible for anyone who has logged into your application at any time in the past.
If you do not match identifiers in applications, then no code changes are required. If you need to map the same user IDs in multiple applications or run ad campaigns with multiple applications, we have added a new API called the Business Mapping API. This allows you to display registered user IDs in applications, as long as all these applications belong to the same business. Learn more about implementing cross promotions.
For users who are not logged into your application, the user ID may change depending on the version of the API you are calling. In version 1.0, API users who are not logged into your application will be referenced by their original Facebook user identifier, while in version 2.0 they will be referenced by the application identifier.
We've added new API endpoints that allow you to tag and invite friends who donβt use your application. These APIs return tokens that can be used to create user interfaces for tags and prompts. These tokens are not intended for caching, and we do not guarantee that they will be stable for 24 hours from the receipt of the API response. They do not match the identifiers used for the data for people who are not logged into your application, and do not match the identifiers of the applications.
Users can verify their application identifiers for each application that they have installed in the Application Editing Options dialog box. Make sure your app users know how to find them when they contact you with support requests.
I really do not understand their logic. This makes much more sense, having a unique identifier for each user, which can be used to check it on any number of applications. In my case, someone logs into our web application, then they also want to log in to the mobile, but they have a different user ID, so there is no way to link 2 together! Eugh