1

I'm trying to retrieve all user's friends and render them in a list view using facebook graph request.

const infoRequest = new GraphRequest( '/me', { parameters: { fields: { string: 'email, name, first_name, middle_name, last_name, picture.type(large), cover, birthday, location, friends' } } }, this._responseInfoCallback );

Anil Hitang
  • 21
  • 1
  • 8
  • What is the response you are getting from the call? Are you getting any error? if any, please tell – Akshay Rao Sep 17 '17 at 16:36
  • I am getting name, email etc, when i console log, but when i console.log friends i get undefined error. I didn't find any means to check whether friends list is availabe – Anil Hitang Sep 17 '17 at 17:01

1 Answers1

2

Facebook doesn't allow you to access your full friends list anymore since API 2.0, just those who also use your app. https://developers.facebook.com/docs/graph-api/reference/v2.2/user/friends.

For further reference you can also check the post Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app

If you still have any queries please let me know. :)

EDIT

You can get the list of friends of the user which are not using this app with the api call given below:-

https://graph.facebook.com/' + facebookUserId + '/invitable_friends?access_token=' + userToken

and then inside the callback of the above api call you can make a new api call and get the list of users friends which are using the app with the call given below:-

https://graph.facebook.com/' + facebookUserId + '/friends?access_token=' + userToken

and then you can concat the result of both the api calls and get the list of all the friends of the user as below:-

let allFriends = firstApiResponseArray.concat(SecondApiResponseArray)

Now allFriends will give the list of all the friends of the user. I hope this is what you are looking for :)

Akshay Rao
  • 3,454
  • 1
  • 15
  • 19