gpt4 book ai didi

ios - 无法在适用于 iOS 的 Facebook SDK 4 上获取好友列表

转载 作者:行者123 更新时间:2023-11-29 12:00:55 24 4
gpt4 key购买 nike

我正在尝试使用 Facebook SDK 获取好友列表,但没有成功。

这是我使用的代码:

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"me/friends"
parameters:@{@"fields": @"fields=id, first_name, last_name, birthday, gender, picture, devices"}
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
if (error == nil) {
NSArray* friends = [result objectForKey:@"data"];
} else {
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];

这是我得到的错误:

2016-05-08 00:07:12.610 App2Gift[48103:676830] Failed getting friend list
2016-05-08 00:07:12.610 App2Gift[48103:676830] Error: Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=100, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 100;
"fbtrace_id" = "G3OpyiU/JKs";
message = "(#100) Unknown fields: fields=id.";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=400, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=(#100) Unknown fields: fields=id., com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0} {
"com.facebook.sdk:FBSDKErrorDeveloperMessageKey" = "(#100) Unknown fields: fields=id.";
"com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey" = 0;
"com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode" = 100;
"com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey" = 400;
"com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey" = {
body = {
error = {
code = 100;
"fbtrace_id" = "G3OpyiU/JKs";
message = "(#100) Unknown fields: fields=id.";
type = OAuthException;
};
};
code = 400;
};
}

使用 parameters as: nil 运行相同但不会返回所有需要的数据。

最佳答案

经过测试并可以使用这些权限:

loginView.readPermissions = @[@"public_profile", @"email", @"user_friends"];

NSString *path = [NSString stringWithFormat:@"/me/friends"];

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:path
parameters:@{@"fields": @"id, name, picture, devices"}
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error)
{

}];

关于ios - 无法在适用于 iOS 的 Facebook SDK 4 上获取好友列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37093741/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com