我正在尝试使用FBRequestConnection检索用户所在的城市和国家/地区。性别,ID,名称似乎有效,但无法检索位置。它只返回(null),我该如何检索它?
[FBRequestConnection
startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSString *facebookId = [result objectForKey:@"id"];
NSString *facebookName = [result objectForKey:@"name"];
NSString *facebookGender = [result objectForKey:@"gender"];
NSString *facebookCity = [result objectForKey:@"location"];
NSLog(@"%@", facebookCity);
}
}];
答案 0 :(得分:0)
查看Graph API的响应
{
"id": "1496537134",
"name": "XXX XXX XXX",
"location": {
"id": "106517799384578",
"name": "New Delhi, India"
}
}
这里的位置是字典,而不是字符串。
NSString *facebookCity = [result objectForKey:@"location"][@"name"];
应该有效。
在获取位置详细信息之前,您需要获得许可, Facebook login with Permission