amar
amar

Reputation: 185

fetching Facebook friend list?

This is giving empty array.Here is my code please help me out Am I missing something here???

 -(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user
        {
         [FBRequestConnection startWithGraphPath:@"/me/friends"
                                             parameters:nil
                                             HTTPMethod:@"GET"
                                      completionHandler:^(
                                                          FBRequestConnection *connection,
                                                          id result,
                                                          NSError *error
                                                          ) {
                                          NSLog(@"me/friends result=%@",result);

                                          NSLog(@"me/friends error = %@", error.description);

                                          NSArray *friendList = [result objectForKey:@"data"];
                                          //[m_allFriends addObjectsFromArray: friendList];
                                      }];
        }

Upvotes: 0

Views: 83

Answers (2)

Bhumit Mehta
Bhumit Mehta

Reputation: 16318

Only those friends who have authorized access to your app will be returned in this array. So if none of your apps have authorized your app it will return empty array.

If you want to test this you can authorize your app from one of your friends account and than when you test is using your account , you will receive 1 object in array

This has changed since Graph API 2.0

Please read following block of information fetched from facebook Graph API docs

  • A user access token with user_friends permission is required to view the current person's friends.

  • This will only return any friends who have used (via Facebook Login) the app making the request.

  • If a friend of the person declines the user_friends permission, that friend will not show up in the friend list for this person.

You can find this here

Upvotes: 0

iBhavin
iBhavin

Reputation: 1261

You can no longer get the entire list of friends. Now the list will be limited to only those friends who also happen to use your app.

To quote Facebook Graph API 2.0 doc:

Permissions

A user access token with user_friends permission is required to view the current person's friends. This will only return any friends who have used (via Facebook Login) the app making the request.

So /me/friends will only return your friends that have logged in and given permission to the same app.(you and your friends need to have permitted your app to use facebook via login)

Upvotes: 1

Related Questions