1

我使用下面的 Objective-c 代码从 facebook 检索朋友列表、id 和生日,这对于朋友列表和 id 工作正常,但返回朋友生日的 null 值。

FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
                              NSDictionary* result,
                              NSError *error) {
NSArray* friends = [result objectForKey:@"data"];
NSLog(@"Found: %i friends", friends.count);
for (NSDictionary<FBGraphUser>* friend in friends) {
    NSLog(@"I have a friend named %@ with id %@  with Birthdate %@", friend.name, friend.id, friend.birthday);
}
}];

我还为friend_birthday设置了权限,但它仍然为朋友的生日返回空值。谁能帮我检索朋友的生日而不是空值?提前致谢

4

2 回答 2

0

你确定你添加了权限'user_birthday',它提供了以年份作为生日属性的生日访问权限

于 2012-12-26T14:49:45.523 回答
0
 NSArray *permissions = [[NSArray alloc] initWithObjects:
                                @"user_birthday",@"friends_hometown",
                                @"friends_birthday",@"friends_location",
                                nil];
 [FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:YES completionHandler: .....

 FBRequest *friendRequest = [FBRequest requestForGraphPath:@"me/friends?fields=name,picture,birthday,location"];
 [ friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) 
{
   NSArray *data = [result objectForKey:@"data"];
   for (FBGraphObject<FBGraphUser> *friend in data) 
   {
      NSLog(@"%@:%@", [friend name],[friend birthday]);
    }
}];
于 2014-05-27T10:26:18.187 回答