views:

113

answers:

1

Hello, I am trying to get the email address from a user. He logs in, I ask permission to access email and he chooses ok. Then I use the graph 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];
}

It gives me only this string: { id = "https://graph.facebook.com/me"; } What did I do wrong?

A: 

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

kudor gyozo