2014-02-10 94 views
0

我知道这个问题已经被问早前很多次,但我无法找到与我相似的任何情况。我正在从Facebook上检索数据并成功获得响应。问题仅限于电子邮件。我只收到电子邮件中的空白。其他一切都很好。从Facebook检索数据,但无法获取电子邮件

这里是我的代码,通过它我检索数据:

NSURL *feedURL = [NSURL URLWithString:@"https://graph.facebook.com/me"]; 
    SLRequest *feedRequest = [SLRequest 
           requestForServiceType:SLServiceTypeFacebook 
           requestMethod:SLRequestMethodGET 
           URL:feedURL 
           parameters:nil]; 
    feedRequest.account = self.facebookAccount; 
    [feedRequest performRequestWithHandler:^(NSData *responseData, 
              NSHTTPURLResponse *urlResponse, NSError *error) 
    { 
     // Handle response 
     if ([urlResponse statusCode] == 200) { 
      NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; 
      NSDictionary *userInfoDictionary = [responseString JSONValue]; 
      FacebookUser *currentFacebookUser = [[FacebookUser alloc] init]; 

      NSNumberFormatter * f = [[NSNumberFormatter alloc] init]; 
      [f setNumberStyle:NSNumberFormatterDecimalStyle]; 
      currentFacebookUser.userId = [f numberFromString:[userInfoDictionary objectForKey:@"id"]]; 
      currentFacebookUser.firstName = [userInfoDictionary objectForKey:@"first_name"]; 
      currentFacebookUser.last_name = [userInfoDictionary objectForKey:@"last_name"]; 
      currentFacebookUser.username = [userInfoDictionary objectForKey:@"username"]; 
      currentFacebookUser.email = [userInfoDictionary objectForKey:@"email"]; 

      [self.delegate facebookUserInformationRequestCompleted:YES facebookUser:currentFacebookUser]; 
     } else { 
      [self.delegate facebookUserInformationRequestCompleted:NO facebookUser:nil]; 
     } 
    }]; 

我得到以下结果:

 {"id":"12345678","name":"Abc Xyz","first_name":"Abc","last_name":"Xyz", 
"link":"https:\/\/www.facebook.com\/ABC12345", 
    "birthday":"09\/09\/1990","hometown":{"id":"12345678", 
    "name":"New York, New York"}, 
    "location":{"id":"12345678","name":"New York, New York"}, 
    "work":[{"employer":{"id":"12345678","name":"Walmart"}, 
    "location":{"id":"12345678","name":"Bentonville, Arkansas"}, 
    "start_date":"0000-00"}],"favorite_athletes":[{"id":"12345678","name":"xyzabc"}], 
    "gender":"female","timezone":5,"locale":"en_US", 
    "verified":true,"updated_time":"2014-02-10T06:03:36+0000", 
    "username":"abc123"} 

我已编辑的姓名和ID,但我得到正确的名称等数据也很好。但是,如果我没有错,我就看不到性别之后的电子邮件地址。

所以任何一个可以告诉我,我在哪里错了?

+1

你有没有尝试过他们与不同的Facebook帐户? ..因为你可以把你的电子邮件作为私人,并不能通过Facebook API访问。 – Haroon

+1

它给一些帐户的电子邮件,但不是所有。 – iBug

回答

0

检查您的remote_app_id和您的包ID。他们应该是一样的。如果他们不是,你将无法获得权限。

检查你的方法,你所要求的权限。在那里你可以检查你是否获得访问权限。如果你没有得到许可,那么它可能是remote_app_id问题。

+1

哦,我已经改变了我的包ID,但不是远程ID。谢谢你有我的问题:) – iBug

相关问题