Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sorry to switch languages here, but I got this to work well in Ruby using <a href="https://github.com/arsduo/koala" rel="nofollow">Koala</a>. I'm using a <a href="https://developers.facebook.com/docs/reference/api/batch/" rel="nofollow">Batch Request</a> as follows:</p> <pre><code> friends = @graph_batch.batch do |batch_api| batch_api.get_connections("me", "friends", {:limit =&gt; 100, :offset =&gt; 0}, :batch_args =&gt; {:name =&gt; "get-friends"}) batch_api.get_objects("{result=get-friends:$.data.*.id}") batch_api.graph_call("method/fql.query", { :query =&gt; "SELECT uid1, uid2 FROM friend WHERE uid2 IN ({result=get-friends:$.data.*.id}) AND uid1 IN (SELECT uid2 FROM friend WHERE uid1=me())" }, "post" ) end </code></pre> <p>That is,</p> <ol> <li>Graph - Get my friends list - /me/friends</li> <li>Graph - Get my friends data - /?ids={result=get-friends:$.data.*.id}</li> <li>FQL - Get all mutual friends - /method/fql.query?query=SELECT uid1, uid2 FROM friend WHERE uid2 IN ({result=get-friends:$.data.*.id}) AND uid1 IN (SELECT uid2 FROM friend WHERE uid1=me())" } <strong>(with proper escaping and POST method)</strong></li> </ol> <p>The third query will return a list of elements, uid1, uid2. From there, you have all the data you need to calculate mutual friend counts. In Ruby, I use the following:</p> <pre><code> friends[2].clone.delete_if { |r| r['uid2'] != "xxxxxxx" }.count </code></pre> <p>Basically, I count all elements in the array where uid2 is a specific ID. I'm sure there's better ways to count, but the data is now yours. Hope this helps, and sorry again for switching languages on you (but what's a language mean when you're using an API anyway?). </p> <p><strong>Edit</strong>: You'll only be able to do about 100 rows at a time. You can adjust the limit / offset parameters to page through results.</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. This table or related slice is empty.
    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