I need to determine whether two (or more) users are friends.
$areFriends = $facebook->api_client->friends_areFriends('12345', '67890');
The method also accepts two arrays and will let you know whether each pair (pulling the member at the same position in each array) is a friend:
$aUsers = array('12345', '67890', '11223'); $bUsers = array('33445', '66778', '99100'); $areFriends = $facebook->api_client->friends_areFriends($aUsers, $bUsers);
Either way, the
Friends.areFriends() returns a
multidimensional array in which each element contains
are_friends elements (with the latter being
false, or empty if the members aren’t
visible due to privacy rules or don’t exist, which is the case with
our fictional users here):
Array (  => Array ( [uid1] => 12345 [uid2] => 33445 [are_friends] => )  => Array ( [uid1] => 67890 [uid2] => 66778 [are_friends] => )  => Array ( [uid1] => 11223 [uid2] => 99100 [are_friends] => ) )
Since the method is symmetric, both arrays need to have the same number of elements in them or you’ll get an invalid parameter error.
If you’d prefer to use FQL to access friends, the equivalent query is:
SELECT uid1, uid2 FROM friend WHERE uid1=uid1 AND uid2=uid2
See Checking Whether Two Users are Friends for more information.