-1

I know it have been asked a lot here, but I can't find a proper answer for that.

I am using Facebook SDK v3.18

I simply want to get user friends list and their pictures .

I've tried so far this:

Login:

FBLoginView *loginView =
    [[FBLoginView alloc] initWithReadPermissions:
     @[@"public_profile", @"email", @"user_friends"]];
    // Align the button in the center horizontally
    loginView.frame = CGRectOffset(loginView.frame, (self.view.center.x - (loginView.frame.size.width / 2)), (self.view.center.y - (loginView.frame.size.height / 2)));
    [self.view addSubview:loginView];

Get user's friends list and their pictures:

[FBRequestConnection startWithGraphPath:@"/me/friends?fields=name,picture"
                             parameters:nil
                             HTTPMethod:@"GET"
                      completionHandler:^(
                                          FBRequestConnection *connection,
                                          id result,
                                          NSError *error
                                          ) {
                          /* handle the result */
                      }];

But the answer is:

{
    data =     (
    );
    summary =     {
        "total_count" = 1216;
    };
}

And non for my friends name or pictures are shown :/

Please put some light for me on this.

Thanks in advance!

gran33
  • 10,218
  • 7
  • 40
  • 67

2 Answers2

2

From the Facebook SDK page, it looks like /me/friends will only return your friends that have logged in and given permission to the same app (i.e. you and your friends need to have permitted your app to use facebook via login).

Marcelo Ribeiro
  • 1,660
  • 11
  • 27
  • What? I logged on and approve my app :/ – gran33 Sep 21 '14 at 16:43
  • I understand that but your friends would need to do that too. You only get your friends that have done the same thing - approved the app. Do you have other FB testing accounts you could use to approve the app? – Marcelo Ribeiro Sep 21 '14 at 16:45
  • That's a different thing I think. What I am trying to say is that, when using FacebookSDK, you are only going to be able to fetch the logged in user's friends who actually gave permission to the same App ID (or signed in using facebook). If you created a new facebook account, became friends with it, and used both to login and therefore give your app the required permission, you could fetch one or another using /me/friends. – Marcelo Ribeiro Sep 21 '14 at 18:50
0

Did you tried below ?

FBRequest* friendsRequest = [FBRequest requestWithGraphPath:@"me/friends?fields=name" parameters:nil HTTPMethod:@"GET"];
    [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 %@", friend.name, friend.id);

        }
        NSArray *friendIDs = [friends collect:^id(NSDictionary<FBGraphUser>* friend) {
            return friend.id;
        }];

 }];

Edit:

Please check this post.

Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app

Community
  • 1
  • 1
bllakjakk
  • 4,965
  • 1
  • 15
  • 26