Can't get email address using facebook sdk for iOS and timeline api for facebook

I am trying to get an email address from a user. He logs in, I ask permission to access the email, and he selects normally. Then I use the graphics API from facebook to access the email address.

- (void) fbDidLogin { btnLogin.isLoggedIn = TRUE; [btnLogin updateImage]; NSString *theURL = [ [NSString stringWithFormat: @"https://graph.facebook.com/me?access_token=%@", facebook.accessToken ]stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding ]; NSLog(@"%@", theURL); [facebook requestWithGraphPath: theURL andDelegate: self]; } ... - (void)request:(FBRequest*)request didLoadRawResponse:(NSData*)data { NSString *response = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]; NSLog(@"%@", response); [response release]; } 

This is how I get the information:

 - (void) request:(FBRequest*)request didLoad:(id)result { if ([result isKindOfClass:[NSDictionary class]]) { NSString *email = [result objectForKey: @"email"]; NSString *name = [result objectForKey: @"name"]; NSString *facebookId = [result objectForKey: @"id"]; //... } } 

It gives me only this line: { id = "https://graph.facebook.com/me"; } { id = "https://graph.facebook.com/me"; } What have I done wrong?

+6
objective-c iphone facebook facebook-graph-api
source share
2 answers

Ah no, it works. I had to use @"me" in [facebook requestWithGraphPath: @"me" andDelegate: self]; instead of url.

+4
source share

I found the answer:

  NSArray *permissions = [[NSArray alloc] initWithObjects:@"user_likes",@"offline_access",@"read_stream",@"publish_stream",@"email",nil]; [facebook requestWithGraphPath:@"me"andParams:params andDelegate:self]; -(void)facebookLoginScreen:(NSDictionary *)result { NSLog(%@,[result objectForKey:@"email"]); } 
+9
source share

All Articles