我正在尝试使用 facebook js sdk 获取 Facebook 好友。代码如下:
<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>
我收到了回复,但内容如下:
Object {data: Array[0]}
我做错了什么?
最佳答案
请删除“status:true”后面的点(.)。您没有获得任何用户,因为您的 friend 没有使用该应用程序。Facebook 更改了自己的 API,我们无法获得所有 friend ,只能获得那些正在使用当前应用程序的 friend 。
请阅读此变更日志:--
关于javascript - Facebook javascript sdk 响应为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24295443/