3

So I'm using the "Facebook-sdk" plugin. I'm initializing Facebook like this:

FB.init({ appId: 'xxxxxxxxxxx', cookie: true, xfbml: true, oauth: true, status: true });

    FB.login(function(){ // get permissions
    }, {scope: 'user_friends, read_friendlists, user_photos, email, publish_actions  '});

    FB.getLoginStatus(function (response) { // to generate AccessToken
      if (response.authResponse) {
        console.log('LoginStatusResponse: ' + JSON.stringify(response, null, 4));
      } else {
        console.log('AuthResponse: No');
      }
    });

Then in response to a button click event, I'm doing:

'click #get_fb_friends' : function(event, template) {

    FB.api( 
      "/me/friends",
      function (response) {
        if (response && !response.error) {
          console.log('GOT them !!!' + JSON.stringify(response, null, 4));
          return response;
        } else {
          console.log('No can do' + JSON.stringify(response, null, 4));
        }
      });
  }

The thing is that I'm getting an empty Data variable:

GOT them !!!{
    "data": []
} 

PS: The query "/me" returns all information about myself, it's the "/me/friends" that doesn't work.

Can it be a permissions problem ?

Alucard
  • 1,486
  • 1
  • 18
  • 30
  • See the answer here http://stackoverflow.com/questions/23417356/facebook-graph-api-v2-0-me-friends-returns-empty-or-only-friends-who-also-use-m#answer-23417628 – Dieter Pisarewski May 22 '14 at 15:44

2 Answers2

2

Facebook has changed its api a few weeks ago,you can only access a list of your friends when they have personally accepted to use your app.. Nothing to do about it

Wampie Driessen
  • 1,519
  • 10
  • 16
1

Like @Wampie said, the API has changed, so you could try to use the v1 API (keep in mind that you'll need to request a new access token).

And you can still invite friends to your app by using the apprequests method.

FB.ui({
  method: 'apprequests',
  message: 'You should learn more about the Platform.'
}, function(){
  console.log(arguments);
});

Example here: https://www.fbrell.com/fb.ui/apprequests

Koen.
  • 21,087
  • 6
  • 75
  • 76