简体   繁体   中英

How can i get Friends Birthday and User Birthday on facebook in Ios sdk

i want to get the user and friends birthday on my application.

i am trying to retrieve birthday data of facebook friends, but it's returning null. I'm using this code:

- (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"]);
             }
         }];

    }
}

But user Birthday and friends birthday are return NULL

The friends_* have been deprecated with the introduction of the v2.0 of the Graph API. So you can't get them anymore. Furthermore, /me/friends will only return those friends which are also using your app.

Also, you try to request some fields which you don't gather the permissions for, which will not work as well.

See

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