使用iOS SDK获取Facebook好友对某些朋友返回null

时间:2012-05-28 21:54:03

标签: ios facebook-graph-api

我正在使用此代码来获取朋友的生日:

- (void)apiGraphFriendsWithBirthdays {
[self showActivityIndicator];

HackbookAppDelegate *delegate = (HackbookAppDelegate *)[[UIApplication sharedApplication] delegate];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
 @"picture,id,name,link,birthday,gender,last_name,first_name",@"fields",
 nil];

[[delegate facebook] requestWithGraphPath:@"me/friends" andParams:params andHttpMethod:@"GET" andDelegate:self];

}

然后我打印以记录我提取的一些内容:

        NSMutableArray *friends = [[NSMutableArray alloc] initWithCapacity:1];
        NSArray *resultData = [result objectForKey:@"data"];
        if ([resultData count] > 0) {
            for (NSUInteger i=0; i<[resultData count] && i < 25; i++) {
                [friends addObject:[resultData objectAtIndex:i]];

                NSDictionary *friend = [resultData objectAtIndex:i];
                long long fbid = [[friend objectForKey:@"id"]longLongValue];
                NSString *name = [friend objectForKey:@"name"];
                NSString *birthday = [[friend objectForKey:@"birthday"] description];
                NSLog(@"id: %lld - Name: %@ - Birthday: %@", fbid, name,birthday);


            }

        } else {
            [self showMessage:@"You have no friends."];
        }
        [friends release];

出于某种原因,我的一些朋友生日是空的,虽然我可以在Facebook上看到他们的生日。

这是我的代码还是某种特定的用户隐私设置?

1 个答案:

答案 0 :(得分:0)

您需要请求权限才能查看'friends_birthday'

Facebook Permissions