我正在使用下面提到的方法来查找朋友列表,但它不起作用。我使用的早期方法(FBRequestConnection)不再起作用,因为它们可能不再受支持。请指导。
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);
}];
我从中得到的回应是:
request friend list:<FBSDKGraphRequest: 0x7fc77af33bc0, graphPath: /me/friendlists, HTTPMethod: GET, parameters: {
"access_token" = CAAIDdxjgZCZAQBAIupnz8fToFBh4YzgdvTAVciQZAZBj1kX8h7iZCYc1WSqVBVmmiCKRuAbymzRVcQeLZAIhhssc6JkB50rsOFJK6KwsuEiK6B1jvPuaUNZAIm2YqlZCg1INs9ZCoyqOo6lmRjjkttxX2RrkWZAUEDxE8lP9DApbyDh5ZChbsPT5zZAsdRMj3tQkVxLXyLaMXxN9rbPxU8lZCs57HbhOQXmkZD;
fields = name;
format = json;
"include_headers" = false;
sdk = ios;
}>
首先需要在登录时传递权限参数"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);
}];