简体   繁体   English

如何在iOS 9 fb sdk 4.8或更高版本中从Facebook获取朋友列表?

[英]How to fetch Friend list from facebook in iOS 9 fb sdk 4.8 or above?

I am using way mentioned below to find friend list but it is not working. 我正在使用下面提到的方法来查找朋友列表,但是它不起作用。 And earlier methods i used (FBRequestConnection) is not working any more may be they are not supported any more. 我使用的早期方法(FBRequestConnection)不再起作用,因为它们不再受支持。 Please guide. 请指导。

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me/friends" parameters:@{@"fields": @"name"} HTTPMethod:@"GET"];
                 [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                     // TODO: handle results or error of request.
                     NSLog(@"request friend list:%@", request);
                 }];

Respsonse i got from this is: 我从中得到的回应是:

request friend list:<FBSDKGraphRequest: 0x7fc77af33bc0, graphPath: /me/friendlists, HTTPMethod: GET, parameters: {
"access_token" = CAAIDdxjgZCZAQBAIupnz8fToFBh4YzgdvTAVciQZAZBj1kX8h7iZCYc1WSqVBVmmiCKRuAbymzRVcQeLZAIhhssc6JkB50rsOFJK6KwsuEiK6B1jvPuaUNZAIm2YqlZCg1INs9ZCoyqOo6lmRjjkttxX2RrkWZAUEDxE8lP9DApbyDh5ZChbsPT5zZAsdRMj3tQkVxLXyLaMXxN9rbPxU8lZCs57HbhOQXmkZD;
fields = name;
format = json;
"include_headers" = false;
sdk = ios;
}>

First of all need to pass the permission parameter "user_friends" at the time of login.Then use the below code to get list. 首先需要在登录时传递权限参数“ user_friends”。然后使用以下代码获取列表。

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/me/friends" parameters:@{@"fields": @"name"} HTTPMethod:@"GET"];
                 [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                     // TODO: handle results or error of request.
                     NSLog(@"request friend list:%@", result);
                 }];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM