【发布时间】:2015-09-09 06:24:58
【问题描述】:
在我的应用程序中,我必须实现 facebook 登录。基于我正在进行集成的 facebook 文档,但是当我获取用户信息时,电子邮件部分对我来说是空的。 有人可以告诉我问题出在哪里。 我正在使用此代码
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
//login.loginBehavior = FBSDKLoginBehaviorBrowser;
[login logInWithReadPermissions:@[@"public_profile",@"email",@"user_friends"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error)
{
// Process error
}
else if (result.isCancelled)
{
// Handle cancellations
}
else
{
if ([result.grantedPermissions containsObject:@"email"])
{
NSLog(@"result is:%@",result);
[login logOut]; // Only If you don't want to save the session for current app
}
}
}];
if ([FBSDKAccessToken currentAccessToken])
{
NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]);
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSLog(@"fetched user:%@ and Email : %@", result,result[@"email"]);
}
}];
}
}
出去放这个
fetched user:{
id = 970029739773026393591;
name = "jace";
} and Email : (null)
FBSDKLog: starting with Graph API v2.4, GET requests for /me should contain an explicit "fields" parameter
【问题讨论】:
标签: ios objective-c iphone facebook