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

问题是我得到一个空的数据变量:

GOT them !!!{
    "data": []
} 

PS:查询"/me"返回有关我自己的所有信息,这是"/me/friends"不起作用的。

可能是权限问题吗?

4

2 回答 2

2

Facebook has changed its api a few weeks ago,you can only access a list of your friends when they have personally accepted to use your app.. Nothing to do about it

于 2014-05-20T23:33:26.870 回答
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

于 2014-05-22T12:35:44.613 回答