0

I am trying to build a web app which use Facebook graph API for login and retrieve User ID, Name and Friend List. I am able to get Name and a ID which is not actual profile id. Only my app recognize that ID. This code is for login button:

<fb:login-button 
        id="fb-btn"
        scope="public_profile,email,user_friends"
        onlogin="checkLoginState();">
        </fb:login-button>

And this is used for API call:

function testAPI() {
         FB.api('me?fields=id,name,email,friends', function(response){
             if(response && !response.error){
                console.log(response);
             }
         })
     }

I am getting user id: "10211305857749793" and empty friend list. But actual user id is 1460690872. How to get actual profile id.

This is the output I am getting:

{id: "10211305857749793", name: "Atul Krishna", email: "atul.krishan1994@gmail.com", friends: {…}} friends:{data: Array(0), summary: {…}}
atultherajput
  • 175
  • 3
  • 18

1 Answers1

1

The ID is just an "App Scoped ID", you cannot get the "real" ID anymore and you do not need it anyway. The App Scoped ID can be used to identify returning users, it will not change in your App.

About friends: You can only get friends who authorized your App too, since v2.0 of the Graph API. More information: Facebook Graph API v2.0+ - /me/friends returns empty, or only friends who also use my application

andyrandy
  • 72,880
  • 8
  • 113
  • 130