Find out if a user is friends with one other user using the Graph API

I am trying to find out if user A is friends with user B, but I do not want the user to have an entire list of friends. Is there a way using the Koala / Graph API to simply find out if user A is friends with user B only using User B's Facebook ID?

+6
source share
2 answers

You can use https://graph.facebook.com/me/friends/ {friend user id}

If they are friends, it will return an identifier and a name, if not an empty array.

+7
source

This is easy to do using 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 add an access token.

 https://graph.facebook.com/fql?q=SELECT uid2 FROM friend WHERE uid1=me() and uid2=123456 

You can also check the multiplicity in one:

 SELECT uid2 FROM friend WHERE uid1=me() and uid2 in (123,1234) 
+1
source

Source: https://habr.com/ru/post/906423/


All Articles