Reputation: 372
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?
Upvotes: 0
Views: 711
Reputation: 11
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
Upvotes: 1