【发布时间】:2015-04-02 12:05:44
【问题描述】:
我尝试使用 iOS Facebook SDK 版本 4。
我完成了登录没有问题,但无法使用图形 API 获取用户电子邮件地址。如果有人有解决方案会很酷。
这里是我的代码,在视图中确实加载了:
_FBButton = [[FBSDKLoginButton alloc] init];
_FBButton.readPermissions = @[@"public_profile", @"email"];
_FBButton.delegate = self;
这里是登录成功的方法:
- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error: (NSError *)error{
if ([FBSDKAccessToken currentAccessToken]) {
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result2, NSError *error) {
if (!error) {
NSLog(@"fetched user:%@", result2);
}
}];
}
}
结果如下:
"first_name" = Jack;
gender = male;
id = 1381385368853232;
"last_name" = Ammer;
link = "https://www.facebook.com/app_scoped_user_id/1381385368853232/";
locale = "fr_FR";
name = "Jack Ammer";
timezone = 2;
"updated_time" = "2015-04-02T07:26:35+0000";
verified = 1;
那为什么我可以得到电子邮件地址?
提前致谢。
编辑
可能问题是因为 facebook 只要求用户提供公共配置文件,检查图片:为什么读取权限不起作用?
【问题讨论】:
-
找到解决办法了吗?
标签: ios objective-c facebook sdk