Reputation: 31
m using facebook graph apis in my app. i want to fetch my fb friends email ids in a tableview in my app fb graph user doesn't provides any property for emails. how can i achive this help me - (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;
}
}];
}
Upvotes: 2
Views: 477
Reputation: 2664
Add this line to your code. Hope it will be helpful to you.
NSLog(@"%@",[user objectForKey:@"email"]);
Upvotes: 1
Reputation: 31304
You cannot obtain e-mail addresses for friends through the Facebook API (with good reason - to prevent spam). You can obtain the current user's e-mail address, but only with an extended permission (more about that here).
Upvotes: 0