-1

I have App on Facebook, and this code using FB JS-SDK:

FB.login(function(response) {
    if (response.authResponse) {
        FB.api('/me', {fields: 'first_name, last_name, email'}, function(response) {
            var user_id = response.id;
            ...
        });
    }
}, {scope: 'public_profile,email'});

The user_id returns only user ID that belongs to my APP. But how can I retrieve the real Facebook user ID from this ID?

I need to show profile using this URL: https://www.facebook.com/profile.php?id=XXXX.

Adam Azad
  • 11,171
  • 5
  • 29
  • 70
quarky
  • 710
  • 2
  • 13
  • 36
  • 1
    You can’t. Facebook introduced app-scoped user ids to increase privacy – so leaving a “loophole” through which you could still get their global id would make little sense. Just request the `link` field as well, that gives you a URL you can use to link to their profile. – CBroe Dec 01 '15 at 14:14
  • Many thanks CBroe. Good to know. – quarky Dec 02 '15 at 23:06
  • CBroe, why don't you post that as an answer instead of a comment! – Emil Vikström Dec 14 '15 at 16:02

1 Answers1

3

Facebook has removed the ability to get the public username or profile ID for a user via the API. However, by using the App Scoped User ID provided by the API, you can still create a link to the user's public profile. For example:

https://www.facebook.com/app_scoped_user_id/{USER_ID}/

(where USER_ID is the User ID provided by the API)

Niraj Shah
  • 15,087
  • 3
  • 41
  • 60