5

Hi I am using Facebook API javascript SDK, and trying to get logged in user friends data Here is the scope i am using

    FB.login(function(response) {
          statusChangeCallback(response);
          }, {
            scope:'publish_actions,user_friends,public_profile',
            return_scopes: true
    });

 FB.api('/me', function(response) {
    $textInput = document.getElementById("searchText");

        var request =  jQuery.ajax({
                        type: "POST",
                        url: "/logged/ajax/facebook",
                        data: response });
        request.done(function( $data ) {
            jQuery(".loadingContent").css( "display", "none" );
            if($data == "success"){
               FB.api('/me/friends', function(data) {
                 console.log(data);
                });
            } else {
                alert($data);
            }
        });
         request.fail(function( jqXHR, textStatus ) {

         });
});

but it returns me

({"data":[],"summary":{"total_count":79}})

data is always empty, though i am getting total count of my facebook friends

Anna Gabrielyan
  • 2,120
  • 3
  • 28
  • 48
  • 1
    Possible duplicate of [Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app](http://stackoverflow.com/questions/23417356/facebook-graph-api-v2-0-me-friends-returns-empty-or-only-friends-who-also-u) – gak Mar 14 '16 at 21:44

1 Answers1

7

Since v2.0, you can only get friends who authorized your App too.

Check out the changelog for more information: https://developers.facebook.com/docs/apps/changelog

This question is also answered in several other threads already:

Community
  • 1
  • 1
andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • 3
    why the downvote? please comment if you downvote, i am happy to fix errors or improve my answer, but it is definitely correct. – andyrandy Mar 02 '16 at 08:23
  • @luschn People be hatin' – davetw12 Mar 11 '17 at 20:01
  • Thank you @luschn, so ({"data":[],"summary":{"total_count":79}}) means the facebook account has 79 friends, but none of them [installed & authorized] the app? – weiwen Jul 17 '18 at 07:48
  • exactly, that´s what it means. "authorized with the user_friends permission", to be specific. – andyrandy Jul 17 '18 at 10:08