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.
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:
If not rand() , you can also use offset and limit
select uid2 from friend where uid1=me() limit 15 offset 15
This will make friend chosen the previous time, not appear again in the new 15 set of friends chosen the next time. I agree its not truly random, because when they say random, there are chances of the previous friends reappearing.