【发布时间】:2015-09-01 07:02:01
【问题描述】:
我想在我的应用程序中获取用户和朋友的生日。
我正在尝试检索 facebook 朋友的生日数据,但它返回 null。我正在使用此代码:
- (IBAction)login_click:(id)sender
{
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email", @"user_friends",@"user_birthday",@"friends_birthday"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error)
{
// Process error
NSLog(@"error is :%@",error);
}
else if (result.isCancelled)
{
// Handle cancellations
NSLog(@"error is :%@",error);
}
else
{
NSLog(@"Login successfull");
[self fetchUserInfo];
}
}
}];
}
-(void)fetchUserInfo
{
if ([FBSDKAccessToken currentAccessToken])
{
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id,name,link,first_name, last_name, picture, email, birthday, bio ,location ,friends ,hometown , friendlists"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error)
{
NSLog(@"result : %@",result);
NSLog(@"user birthday : %@",[result valueForKey:@"birthday"]);
NSLog(@"friends Birthday : %@",[result valueForKey:@"friends_birthday"]);
}
}];
}
}
但用户生日和朋友生日返回NULL
【问题讨论】:
标签: ios iphone facebook facebook-graph-api facebook-ios-sdk