0

I'm trying to get facebook friends using facebook js sdk. The code is the following:

<script>
     window.fbAsyncInit = function() {
       FB.init({
        appId      : 'app_id_here',
        status     : true,·
        cookie     : true,
        xfbml      : true,
        oauth      : true,
        });
        FB.getLoginStatus(function(response) {
          if (response.status === 'connected') {
            FB.api('/me/friends', function(r){
              if (r && !r.error){
                console.log(r);
              } else {
              console.log('Something goes wrong', r);
            }
          });
        }
      });
        };

            //Load the SDK async
            (function(d){
              var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
              js = d.createElement('script'); js.id = id; js.async = true;
              js.src = "//connect.facebook.net/en_US/all.js";
              d.getElementsByTagName('head')[0].appendChild(js);
              }(document));
            </script>
            <fb:login-button scope="user_friends,email" autologoutlink="true" onlogin="window.location = '#'">
            </fb:login-button>

I'm getting an response but it's like this:

Object {data: Array[0]}

What am I doing wrong?

Matei
  • 372
  • 1
  • 8
  • 21
  • Nothing is my guess. My guess is that you don't have any friends that are also using the app. /me/friends only return friends that are also using the app – WizKid Jun 18 '14 at 21:43
  • i read that is returning all the friends. hmmm – Matei Jun 18 '14 at 21:47
  • Directly from https://developers.facebook.com/docs/graph-api/reference/v2.0/user/friends "This will only return any friends who have used (via Facebook Login) the app making the request." – WizKid Jun 18 '14 at 21:48
  • on read_friendlists there's a note: to access the person's friends you should request the user_friends permission, not this permission – Matei Jun 18 '14 at 21:50
  • Yes? It doesn't say it will return all friends. – WizKid Jun 18 '14 at 21:51
  • well, then how can i access all the friends? i can't find anything out there.. – Matei Jun 18 '14 at 21:54
  • You can't. I would recommend reading http://stackoverflow.com/questions/23417356/facebook-graph-api-v2-0-me-friends-returns-empty-or-only-friends-who-also-use-m/23417628#23417628 – WizKid Jun 18 '14 at 21:55

1 Answers1

1

Please remove dot(.) sign after 'status:true'. You are not getting any user becuase your friends not using that application.Facebook has changed own API,We can't get all friends , Only those friends that are using current application.

Please read this changelog:--

https://developers.facebook.com/docs/apps/changelog