我知道這個問題已經被問早前很多次,但我無法找到與我相似的任何情況。我正在從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,但我得到正確的名稱等數據也很好。但是,如果我沒有錯,我就看不到性別之後的電子郵件地址。
所以任何一個可以告訴我,我在哪裏錯了?
你有沒有嘗試過他們與不同的Facebook帳戶? ..因爲你可以把你的電子郵件作爲私人,並不能通過Facebook API訪問。 – Haroon
它給一些帳戶的電子郵件,但不是所有。 – iBug