Facebook Developer API iOS,age_range返回NULL

时间:2014-08-03 16:15:51

标签: ios facebook facebook-graph-api facebook-ios-sdk

这是我的代码,我在这里做错了什么?请记住,我使用FBLoginView,其他字符串返回实际有效结果,而不是年龄范围。在此先感谢, - 丹尼尔

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
                        user:(id<FBGraphUser>)user {

NSString *userID = [NSString stringWithFormat:@"%@", user.objectID]; //objectID instead?
NSLog(@"userID = %@", userID);

NSString *nameFull = [NSString stringWithFormat:@"%@", user.name];
NSLog(@"nameFull = %@", nameFull);

NSString *firstName = [NSString stringWithFormat:@"%@", user.first_name];
NSLog(@"firstName = %@", firstName);

NSString *middleName = [NSString stringWithFormat:@"%@", user.middle_name];
NSLog(@"middleName = %@", middleName);

NSString *lastName = [NSString stringWithFormat:@"%@", user.last_name];
NSLog(@"lastName = %@", lastName);

NSString *link = [NSString stringWithFormat:@"%@", user.link];
NSLog(@"link = %@", link);

NSString *gender = [NSString stringWithFormat:@"%@", [user objectForKey:@"gender"]];
NSLog(@"gender = %@", gender);

NSDictionary *ageRangeDict = [user objectForKey:@"user_age_range"];
NSString *ageRange = [NSString stringWithFormat:@"%@-%@",
                      [ageRangeDict objectForKey:@"min"],
                      [ageRangeDict objectForKey:@"max"]];

NSLog(@"ageRange = %@", ageRange);
}

2 个答案:

答案 0 :(得分:1)

更改此行:

NSDictionary *ageRangeDict = [user objectForKey:@"user_age_range"];

对此:

NSDictionary *ageRangeDict = [user objectForKey:@"age_range"];

参考:Link

答案 1 :(得分:0)

使用“age_range”代替

根据API