0

I am trying fetch my Friends who are using my application from facebook and but in the response i am getting empty list list. Please guide me what i am doing wrong. I am using the following code

[[FBRequest requestForMe] startWithCompletionHandler: ^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
                if (error) {
                    //error
                    NSLog(@"%@",error);
                }else{
                    FBRequest* friendsRequest = [FBRequest requestForMyFriends];
                    [friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,NSDictionary* result,NSError *error) {
                        NSArray* friends = [result objectForKey:@"data"];

                        NSLog(@"%@",result);

                        for (NSDictionary<FBGraphUser>* friend in friends)
                        {
                            NSLog(@"%@ %d",friend.username,[friend.id intValue]);
                        }
                    }];
                }
            }];

Thanks

btmanikandan
  • 1,923
  • 2
  • 25
  • 45

2 Answers2

0

Possible reasons:

1) You don't have the rights to get connections of this account (wrong apikey/passkey or rights not properly set)

2) Check what is stored in "result" variable and the answer status: it may guide you in some way.

3) Finally, try to get some simpler informations (like your own username) to be sure you have access to these informations.

Besoul
  • 35
  • 6
0

In the new version of Facebook's API you will get ONLY friends that installed the app (i.e. is_app_user is 1). You can't get friends who haven't logged in with your app anymore. Instead, you can get taggable_friends. This will return a list with all of your friends, but here "id" field will be different, not the real facebook id. Its only for tagging, i.e. for passing to field "tags" like:

 NSDictionary *params = @{@"message":self.invitationText.text,
                         @"tags":ids,
                         @"caption":@"...",
                         @"name":@"...",
                         @"place":@"123456789",
                         @"link":APP_STORE_URL};

[FBRequestConnection startWithGraphPath:@"/me/feed"
                             parameters:params
                             HTTPMethod:@"POST"
                      completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                            //...
                      }];
arturdev
  • 10,884
  • 2
  • 39
  • 67