Question:

How to get the friend list for a particular Facebook user?

 

 

 

Answer:

Appreciate if you can like this page if you find it useful! - Click "Like"

There are basically 2 cases in getting the friend list for a "particular Facebook user".

  • The "particular Facebook user" is actually the current session user (i.e. the user who is using your app or connecting to your external web site currently). (I believe the case for acting on behalf of an offline user offline access ext permission granted fall into this category).

  • The "particular Facebook user" is not the current session user (e.g. that user is actually a friend of the current session user).

I believe all of us should have no problem for the first case.

Now, for the second case, if you try to get the friend's friend list by accessing "/{userid}/friends" via the Graph API, you will encountered an exception

"(#604) Can't lookup all friends of 501679505; can only lookup for the logged in user (100000704282029) or for pairs of users"

(or get a 500 error from your browser).

 

Someone has mentioned that getting the friend's friend list can be done by using FQL (I haven't tried that). However, I believe this already has violated the TOS. Below is what I have seen,

III. Storing and Using Data You Receive From Us

1. You must give users control over their data by posting a privacy policy that explains what data you collect, and how you will use, store, and/or transfer their data.
2. You may cache data you receive from the Facebook API in order to improve your application’s user experience, but you should try to keep the data up to date. This permission does not give you any rights to such data (including the right to transfer) absent explicit consent from the users who own the data.
3. Users give you their basic account information when they connect with your application. For all other data, you must obtain explicit consent from the user who provided the data to us before using it for any purpose other than displaying it back to the user on your application. A user’s friends’ data can only be used in the context of the user’s experience on your application.
http://developers.facebook.com/policy/#policies

My view is that using a friend list of a user's friend is already outside the context of the user's experience on the application (as we are supposed to use only up to the user's friend data).

 

 

 

Find my FAQ on Facebook Development useful? Download the PDF for all the FAQs HERE!