Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No, this can't be done using the Graph API or FQL. The furthest you can get is to select information from the user table relating to your friends, such as their friends count, by doing a subselect in your query like this:</p> <pre><code>SELECT uid, friend_count FROM user WHERE uid IN ( SELECT uid1 FROM friend WHERE uid2 = me() ) </code></pre> <p>but that doesn't even get you to 2 levels in your original question, because many of those friends of yours will have friends in common, and so the sum of those counts will be vastly more than the number of friends of friends you have. In order to get the information you need, what you would need to do is pull out a list of ids of friends of friends and then count them yourself by executing a query like this</p> <pre><code>SELECT uid1 FROM friend WHERE uid2 in ( SELECT uid1 FROM friend WHERE uid2 = me() ) </code></pre> <p>However, if you <a href="https://developers.facebook.com/tools/explorer/?fql=SELECT%20uid1%0AFROM%20friend%0AWHERE%20uid2%20in%20(%0A%20%20%20%20SELECT%20uid1%0A%20%20%20%20FROM%20friend%0A%20%20%20%20WHERE%20uid2%20%3D%20me()%0A%20%20%20%20)" rel="nofollow">try to execute this</a>, you'll get an error that looks something like:</p> <pre><code>{ "error": { "message": "Can't lookup all friends of 36807322. Can only lookup for the logged in user or the logged in user's friends that are users of your app.", "type": "NoIndexFunctionException", "code": 604 } } </code></pre> <p>and if you try to query your friends' friend lists one by one on the Graph API, you'll get the same error message, as described <a href="http://facebook.stackoverflow.com/questions/1330123/get-a-list-of-friends-of-a-friend-on-facebook">here</a> (thanks Igy for this link).</p> <p>Consequently, there is no way whatsoever to do what you want to do using the existing APIs (unless, of course, you get a sufficiently massive user-base for your Facebook app that you can incrementally construct a graph of the user's friends of friends using access tokens for a multitude of <em>other</em> users of your app - but I assume that such a 'solution' is not helpful to you!)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload