这是我的代码,我只获取用户名和用户的Facebook ID.
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login
logInWithReadPermissions: @[@"public_profile",@"email",@"user_friends"]
fromViewController:self
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Process error");
} else if (result.isCancelled) {
NSLog(@"Cancelled");
} else {
if ([FBSDKAccessToken currentAccessToken]) {
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSLog(@"fetched user:%@", result);
}
}];
} NSLog(@"Results=%@",result);
NSLog(@"Logged in");
}
}];
Run Code Online (Sandbox Code Playgroud)
它也会给出一些像这样的错误 -
-canOpenURL:URL失败:"fbauth2:/" - 错误:"(null)" - scanOpenURL:URL失败:"fbauth2:/" - 错误:"(null)"
FBSDKLog:从Graph API v2.4开始,对/ me的GET请求应该包含一个显式的"fields"参数