我使用下面的objective-c代码来回复朋友列表,id和来自facebook的生日,这对于朋友列表和id工作正常但是为朋友的生日返回空值。
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设置了权限,但仍然为朋友的生日返回空值。有人可以帮我检索朋友的生日而不是空值吗?提前致谢
答案 0 :(得分:0)
您确定添加了“user_birthday”权限,它可以访问带有年份的生日作为生日属性
答案 1 :(得分: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]);
}
}];