Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph API: Getting a random N friends?

I'm unsure if this is possible --

I'm developing an Android game, and I want it to include profile pictures of 15 random friends.

However, it seems my only option is to call the graph API "/me/friends" (several times, with paging) to get all of a users friends, store the list, then randomly select a subset of friends and retrieve their profile photos.

I was wondering if there's a single call to the Graph API to sort randomly, or somehow reduce the footprint of this job, so that I can use their server-side ?limit=15 to reduce the requests my app has to make.

Thanks!

like image 220
linked Avatar asked Dec 20 '11 03:12

linked


1 Answers

This is possible via FQL query which you can run with Graph API

SELECT uid, name FROM user WHERE uid IN (
  SELECT uid2 FROM friend WHERE uid1 = me()
) ORDER BY rand() limit 15

To get it via Graph API you just need to issue GET request to:

GET http://graph.facebook.com/fql?q={QUERY_HERE}
like image 101
Juicy Scripter Avatar answered Sep 17 '22 18:09

Juicy Scripter