I'm trying to find out if User A is friends with User B but I don't want User A's entire list of friends. Is there a way, using Koala / the Graph API to simply find out if User A is friends with User B just using User B's Facebook ID?
You can use https://graph.facebook.com/me/friends/{friend's user id}
If they are friends it will return the ID and Name, if not an empty array.
This can be done easily with FQL.
query = "SELECT uid2 FROM friend WHERE uid1=me() and uid2=FRIEDS ID HERE"
@rest = Koala::Facebook::API.new(oauth_access_token)
# in 1.1 or earlier, use RestAPI instead of API
@rest.fql_query(query) # convenience method
You can test it here if you append an access token.
https://graph.facebook.com/fql?q=SELECT uid2 FROM friend WHERE uid1=me() and uid2=123456
You can also check multiples at one with:
SELECT uid2 FROM friend WHERE uid1=me() and uid2 in (123,1234)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With