我已经关注了图表api,但我得到了响应
context = {
id = dXNlcl9jb250ZAXh0OgGQ2NxhPU1adsVlI9wHXlABJbFICZC9PYfcDq57EiAdimkf6Um0P7dgco2lU1qdiM98jXp5hXpZCVkjBeN0DHCROSZAjio6JAD7gmkIZCqTxVp6dNwZD;
};
id = 1306652987;
}
我的代码是
FBSDKAccessToken *access = [FBSDKAccessToken currentAccessToken];
if (access!=nil)
{
NSDictionary *params = @{
@"fields": @"context.fields(mutual_friends)",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"1306652987"
parameters:params
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
NSLog(@"result %@",result);
// Handle the result
}];
}
else
{
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"public_profile", @"email",@"user_friends"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error)
{
// Process error
}
else if (result.isCancelled)
{
// Handle cancellations
}
else
{
///me/mutualfriends/[OTHER ID]/?fields=name,picture
NSDictionary *params = @{
@"fields": @"context.fields(mutual_friends)",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"1306652987"
parameters:params
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
NSLog(@"result %@",result);
// Handle the result
}];
if ([result.grantedPermissions containsObject:@"email"])
{
NSLog(@"result is:%@",result);
}
}
}];
}
但是在图形API资源管理器中我得到了正确的输出,其中有共同的朋友姓名和身份以及共同朋友的总数,但我无法在我的代码中获得完整的答案
答案 0 :(得分:-1)
我遇到了同样的问题。我犯了使用id / user_id而不是上下文id的错误。
CursorLoader
所以它应该是(在Swift中)
context = {
id = dXNlcl9jb250ZAXh0OgGQ2NxhPU1adsVlI9wHXlABJbFICZC9PYfcDq57EiAdimkf6Um0P7dgco2lU1qdiM98jXp5hXpZCVkjBeN0DHCROSZAjio6JAD7gmkIZCqTxVp6dNwZD;
};
id = 1306652987;
也!共同的朋友必须已登录应用程序并获得“user_friends”的App权限。
所以你的登录应该是这样的:
FBSDKGraphRequest(graphPath: "dXNlcl9jb250ZAXh0OgGQ2NxhPU1adsVlI9wHXlABJbFICZC9PYfcDq57EiAdimkf6Um0P7dgco2lU1qdiM98jXp5hXpZCVkjBeN0DHCROSZAjio6JAD7gmkIZCqTxVp6dNwZD", parameters: nil).startWithCompletionHandler({ (connection, result, error) -> Void in
if (error == nil){
//everything works print the user data
print(result)
} else {
print(error.description)
}
})