gpt4 book ai didi

ios - FBSDK findByGraphPath (me) 不返回电子邮件,即使有权限和显式字段

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:54:41 24 4
gpt4 key购买 nike

我尝试从已登录的 Facebook 用户至少获取 ID、用户名和电子邮件。我首先使用权限类型登录:电子邮件。如果成功,尝试获取 FBSDKGraphRequest,它会返回除电子邮件之外的所有可能值。

我也尝试过添加 public_profile 之类的权限,但无论如何我都尝试过,但我没有收到电子邮件。我查看了开发人员仪表板,默认情况下似乎已批准电子邮件。

FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
[loginManager logInWithReadPermissions:@[@"email"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
return;
} else if (result.isCancelled) {
return;
}

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, gender, first_name, last_name, locale, email"}];

[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
return;
}

NSLog(@"Fetched user: %@", result);
}];
}];

最佳答案

你的代码应该是这样的

-(void)loginWithFacebookButtonTouchUpInside
{
if(![FBSDKAccessToken currentAccessToken])
{
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email",@"public_profile"] fromViewController:nil handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
// Process error
}
else if (result.isCancelled)
{
// Handle cancellations
}
else
{
// If you ask for multiple permissions at once, you
// should check if specific permissions missing
[self userLoggedIn];
}

}];
}else{
//error "Authentication is not done"
}
}

- (void)userLoggedIn
{
[FBSDKProfile enableUpdatesOnAccessTokenChange:NO];
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"name, email,first_name,last_name"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id userInfo, NSError *error) {
if (!error) {
{

}
}
}];
}

关于ios - FBSDK findByGraphPath (me) 不返回电子邮件,即使有权限和显式字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35333917/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com