简体   繁体   中英

Fetching Facebook friends with iOS SDK returns null on some friends

I am using this code to fetch friends birthday:

- (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];

}

Then I'm printing to log some of what I fetched:

        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];

for some reason some of my friends birthdays are null although I can see their birthdays on Facebook.

Is that something on my code or is it some kind of specific user privacy settings?

You need to request permissions to view 'friends_birthday'

Facebook Permissions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM