Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if multiple user ids are friends with a particular person

I want to know which people in a list of people are friends with this user. Is there a graph api call that can return the subset of ids that is the user's friends? I've tried:

/me/friends/?ids=xxxxx,xxxx

I know I can use a batch call an do something like this:

/me/friends/xxxx /me/friends/xxxxx

but it would be nice to do it in one call.

like image 848
karenism Avatar asked Mar 22 '12 21:03

karenism


1 Answers

There wasn't an easy way to do this with the graph api, but I was able to do it with an FQL query:

query = '{
"are_friends":"SELECT+uid2+FROM+friend+WHERE+uid1=me()+and+uid2+in('+people_array.join()+')+limit+10",
"friend_meta":"SELECT+uid,first_name,last_name,name,pic_square+FROM+user+where+uid+in(SELECT+uid2+FROM+%23are_friends)"}'

The friend_meta json object in the result will have all the meta info you are looking for. It's one call, and more efficient and cleaner than the batch calls.

like image 135
karenism Avatar answered Nov 09 '22 14:11

karenism