在我的应用程序中使用facebook graph apis。 我想要获取我的朋友的电子邮件ID 在我的应用程序的tableview中 fb graph用户不提供电子邮件的任何属性。 我怎么能做到这一点 帮我 - (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView { self.userInfoTextView.hidden = NO;
// Fetch user data
[FBRequestConnection
startForMeWithCompletionHandler:^(FBRequestConnection *connection,
id<FBGraphUser> user,
NSError *error) {
if (!error) {
NSString *userInfo = @"";
// Example: typed access (name)
// - no special permissions required
userInfo = [userInfo
stringByAppendingString:
[NSString stringWithFormat:@"Name: %@\n\n",
user.name]];
// Example: typed access, (birthday)
// - requires user_birthday permission
userInfo = [userInfo
stringByAppendingString:
[NSString stringWithFormat:@"Birthday: %@\n\n",
user.birthday]];
// Example: partially typed access, to location field,
// name key (location)
// - requires user_location permission
userInfo = [userInfo
stringByAppendingString:
[NSString stringWithFormat:@"Location: %@\n\n",
user.location[@"name"]]];
// Example: access via key (locale)
// - no special permissions required
userInfo = [userInfo
stringByAppendingString:
[NSString stringWithFormat:@"Locale: %@\n\n",
user[@"locale"]]];
// Example: access via key for array (languages)
// - requires user_likes permission
if (user[@"languages"]) {
NSArray *languages = user[@"languages"];
NSMutableArray *languageNames = [[NSMutableArray alloc] init];
for (int i = 0; i < [languages count]; i++) {
languageNames[i] = languages[i][@"name"];
}
userInfo = [userInfo
stringByAppendingString:
[NSString stringWithFormat:@"Languages: %@\n\n",
languageNames]];
}
// Display the user info
self.userInfoTextView.text = userInfo;
}
}];
}
答案 0 :(得分:0)
您无法通过Facebook API获取朋友的电子邮件地址(有充分理由 - 防止垃圾邮件)。您可以获取当前用户的电子邮件地址,但只能获得扩展权限(more about that here)。
答案 1 :(得分:0)
将此行添加到您的代码中。希望它对你有所帮助。
NSLog(@"%@",[user objectForKey:@"email"]);