因此我的登录范围为fb-login
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email", @"user_location"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
// Process error
NSLog(@"error %@",error);
} else if (result.isCancelled) {
// Handle cancellations
NSLog(@"Cancelled");
} else {
if ([result.grantedPermissions containsObject:@"email"]) {
// Do work
NSLog(@"%@",result);
}
}
}];
我使用以下代码从facebook检索用户名,用户ID,电子邮件。
我无法检索用户的位置。帮帮我
NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
[parameters setValue:@"id,name,email,location" forKey:@"fields"];
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:parameters]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSLog(@"%@",result objectForKey:@"name");
}
}];