gpt4 book ai didi

ios - 解析接收邮件FB SDK

转载 作者:行者123 更新时间:2023-11-29 02:52:25 26 4
gpt4 key购买 nike

我在解析用户的电子邮件时遇到了麻烦。我可以通过 fb graph api 从用户那里获取几乎所有东西。但它不包含电子邮件属性。任何想法,如何获得它?如果我执行 NSlog,它总是返回 null。

{
NSArray *permissionsArray = @[@"email", @"basic_info"];
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
// Was login successful ?
if (!user) {
if (!error) {
NSLog(@"The user cancelled the Facebook login.");
}else {
NSLog(@"An error occurred: %@", error.localizedDescription);
}
// Callback - login failed
if ([delegate respondsToSelector:@selector(commsDidLogin:)]) {
[delegate commsDidLogin:NO];
}
}else if (user.isNew) {
NSLog(@"User signed up and logged in through Facebook!");
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSDictionary<FBGraphUser> *prop = (NSDictionary<FBGraphUser> *)result;
NSDictionary *userData = (NSDictionary *)result;
[[PFUser currentUser] setObject:prop.id forKey:@"fbid"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] setObject:prop.first_name forKey:@"firstname"];
[[PFUser currentUser] saveInBackground];
[[PFUser currentUser] setObject:prop.last_name forKey:@"lastname"];
[[PFUser currentUser] saveInBackground];
NSString *mail = userData[@"email"];
[[PFUser currentUser] setObject:mail
forKey:@"email"];
[[PFUser currentUser] saveInBackground];


NSLog(@"prop %@", prop);



}else {
NSLog(@"User logged in through Facebook!");
NSLog(@"Welcome Screen I am %@", [[PFUser currentUser] username]);
}
}];
}
else {
//HERE
NSLog(@"Error getting the FB username %@", [error description]);
}
[[PFUser currentUser] saveInBackground];
// Callback - login successful
if ([delegate respondsToSelector:@selector(commsDidLogin:)]) {
[delegate commsDidLogin:YES];
}
}];
}

最佳答案

并非每个 Facebook 用户都会公开相同的信息作为其公开个人资料的一部分,email 字段是您需要接受的一个特别的地方,它通常不会被公开。

您返回的 userData NSDictionary 将仅填充此人公开的信息,因此请根据每个用户的需要处理丢失的 key 。

要阅读的文档:

关于ios - 解析接收邮件FB SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24350412/

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