iOS -deprecated permission-facebook friends birthday using Graph API

后端 未结 2 1814
温柔的废话
温柔的废话 2020-12-22 02:06

I am new to iOS . I am trying to fetch birthdays of all friends from a Facebook account. I followed Developers.facebook

I have requested all the nec

2条回答
  •  孤城傲影
    2020-12-22 02:45

    I have fetched friends by this code in new facebook sdk. This might be helpful.

    NSArray *permissions =     [NSArray arrayWithObjects:@"email", @"user_birthday",@"friends_hometown",@"friends_birthday",@"friends_location",@"publish_stream",@"user_friends",@"public_profile",nil];
    
    [self appDelegate].session = [[FBSession alloc] initWithPermissions:permissions];
    
    [[self appDelegate].session openWithCompletionHandler:^(FBSession *session,
                                                            FBSessionState status,
                                                            NSError *error) {
    
        if(!error)
        {
            NSLog(@"success");
            [self fetchFriends];
        }
        else
        {
            NSLog(@"failure");
        }
    
    
    
    }];
    

    then method fetch friend is

    -(void)fetchFriends
    {
        if ([self appDelegate].session.isOpen)
        {
            [FBSession setActiveSession:[self appDelegate].session];
            FBRequest *friendRequest = [FBRequest requestForGraphPath:@"/me/friends?fields=name,picture,birthday,location"];
            [ friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                NSArray *data = [result objectForKey:@"data"];
    
                NSLog(@"response : %@",data);
    
                for (FBGraphObject *friend in data)
                {
                    NSLog(@"name : %@ , bday : %@", [friend name],[friend birthday]);
    
                    [tempArray addObject:friend];
                }
            }];
        }
    }
    

提交回复
热议问题