空的Facebook好友列表

3

我正在使用“Facebook-sdk”插件。我像这样初始化Facebook:

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');
      }
    });

然后,在响应按钮点击事件时,我正在执行以下操作:

'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));
        }
      });
  }

问题在于我得到了一个空的Data变量:
GOT them !!!{
    "data": []
} 

注意:查询"/me"会返回关于自己的所有信息,但是"/me/friends"却不可用。

这可能是一个权限问题吗?


请在此处查看答案:https://dev59.com/9GAg5IYBdhLWcg3wlbxh - Dieter Pisarewski
2个回答

2

几周前,Facebook更改了其API,现在只有当你的朋友个人同意使用你的应用程序时,你才能访问他们的好友列表。对此无可奈何。


但是如果我无法选择他们,那么我该如何邀请他们使用我的应用程序呢? - Alucard

1

就像@Wampie所说,API已经改变,因此您可以尝试使用v1 API(请记住您需要请求新的访问令牌)。

而且,您仍然可以使用apprequests方法邀请朋友使用您的应用程序。

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

以下是示例: https://www.fbrell.com/fb.ui/apprequests


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接