Facebook API: getting random N friends?

I'm not sure if this is possible -

I am developing an Android game and I want it to include profile photos of 15 random friends.

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

I was wondering if there is one API call for sorting randomly or somehow reduce the size of this job so that I can use their server side ?limit=15 to reduce the number of requests that my application should execute.

Thanks!

+8
android facebook facebook-graph-api
source share
2 answers

This is possible with a FQL query, which you can run using the 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 through the Graph API, you just need to issue a GET request:

 GET http://graph.facebook.com/fql?q={QUERY_HERE} 
+21
source share

If not rand (), you can also use offset and limit

select uid2 from a friend, where uid1 = me () limit 15 offset 15

This will make the friend choose the previous time, and not appear again in the new 15 friends selected next time. I agree that it is not random, because when they say random, there are chances for the reappearance of previous friends.

0
source share

All Articles