Get the relationship (each other, each other) between two Facebook ids facebook api

How to check the connection between two facebook ids.? Friend, friend of each other or no relationship. By fql or graph api methods (whatever).

I know how to get friends list, common facebook id friends. But I need the right method that can give a connection between the two Facebook IDs. I have Googled a lot, but have not received anything related to my problem.

+4
source share
2 answers

I got the solution by checking with fql queries.

//$target_id=id of user to check relationship //$source_id=logged in user $query="SELECT uid, name, work FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = $target_id AND uid2=$source_id) ORDER BY name"; $user_info=$this->facebook->api(array('method'=>'fql.query', 'query'=>$query)); if(!empty($user_info)) { $degree='friend'; } else { $query="SELECT uid, name, work FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 IN (SELECT uid2 FROM friend WHERE uid1 = $target_id) AND uid2=$source_id) ORDER BY name"; $user_info=$this->facebook->api(array('method'=>'fql.query', 'query'=>$query)); // we can check friend-of-friend for app user friends if(!empty($user_info)) { $degree='friend-of-friend'; } else{ $degree='none'; } } 

Please answer if anyone knows any simple method.

+1
source
  SELECT uid2 FROM friend WHERE uid1 = me() AND uid2 = {YOUR_FRIEND2_ID} 

With this FQL query, you can check if the link identifier is a friend of the user who is currently logged in. It will return an empty array if users are not friends. Facebook does not give you friends as a friend, so you cannot go beyond the limits of a registered user.

To read the friends table, you need any valid access_token to retrieve the friends of the current session user

This is the only user to request this table, friends of friends cannot be restored.

official Facebook documentation in the FQL friends table

+1
source

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


All Articles