【问题标题】:I am trying to get my friend name and ids with graph api v2.4, but data returns empty:我正在尝试使用 graph api v2.4 获取我的朋友姓名和 ID,但数据返回空:
【发布时间】:2015-12-21 12:59:35
【问题描述】:

嗨,我正在尝试获取使用我的应用程序的 Facebook 好友列表,当我尝试此功能时,我得到了空数据

我的示例代码

let request: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me/friends", parameters: nil, HTTPMethod: "GET")

    request.startWithCompletionHandler { (connection : FBSDKGraphRequestConnection!, result : AnyObject!, error : NSError!) -> Void in
        if error == nil {
            print("Friends are : \(result)")
        } else {
            print("Error Getting Friends \(error)");
        }
    }

我的输出是

FBSDKLog: starting with Graph API v2.4, GET requests for /me/friends should  contain an explicit "fields" parameter
ID is: 964865453559288
2015-12-21 18:25:55.635[12226:218972] fb_id 964865453559288
Friends are : {
data =     (
);
}

【问题讨论】:

  • 使用“me/taggable_friends”而不是“me/friends”
  • 我试过了,但没用,兄弟
  • 那么请使用最新版本的sdk并使用taggable好友
  • 兄弟只使用最新版本
  • 那么它应该可以工作。 .我的代码工作正常

标签: ios swift fb-graph fbsdk


【解决方案1】:

使用 user_id 来获取朋友。它工作正常。试试看

-(void)fetchFriendList:(NSString*)userid
{

    NSString *string = [NSString stringWithFormat:@"/%@/taggable_friends",userid];

    FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                  initWithGraphPath:string
                                  parameters:nil];
    [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                          id result,
                                          NSError *error) {

    ///// your results
    }];




}

【讨论】:

  • Bascally 我正在传递用户 ID
  • FBSDk 发生了一些变化,没有得到任何数据
猜你喜欢
  • 2011-03-26
  • 2018-10-31
  • 2016-04-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多