How to get mutual friends in facebook

facebook Sometimes you may need to retrieve mutual friends between 2 facebook users. Then using this simple api call you can retrieve the mutual friends list. friends.getMutualFriends is a legacy api. But you can easily call this method using php-sdk legacy api calling system.

function getMutualFriends($facebook, $uid1, $uid2){
    try {
        $param  =   array(
                    'method'  => 'friends.getMutualFriends',
                    'source_uid'    => $uid1,
                    'target_uid'  => $uid2,
                    'callback'=> ''
        $mutualFriends   =   $facebook->api($param);
        return $mutualFriends;
    catch(Exception $o) {

    return '';
mahmud ahsan

Computer programmer and hobbyist photographer from Bangladesh, lives in Malaysia. My [Business | Twitter | Linkedin | Instagram | Flickr | 500px]

You may also like


  • VXG
    August 2, 2010 at 11:19 am

    Its really good, I tried for my company’s accounts. Thanks.

  • mctaco
    September 9, 2010 at 7:31 am

    hi, does it require extended permissions to do this? thanks

    • mctaco
      September 9, 2010 at 8:02 am

      Ok it finally worked for me thanks! Source is the user that has the session token, destination the one you want to compare with. You do not need extended permissions and you get back an array with the user ids who are mutual friends. Thanks again!

    • mahmud ahsan
      mahmud ahsan
      September 12, 2010 at 11:23 pm


  • Kishan
    September 14, 2010 at 8:20 pm

    Can you use this for pages?

    • mahmud ahsan
      mahmud ahsan
      September 14, 2010 at 8:24 pm

      It will work for logged in user, i think its possible for page app also

      • Kishan
        November 30, 2010 at 8:42 am

        How can I implement this with the Javascript SDK?

  • khandownloads
    September 28, 2010 at 1:52 pm


    In FBML mode the application is displaying both name and pics of my friends who is using my app.Now I want to display the in iframe mode. I am getting errors saying fb:profilepic and fb:name are not recognizing tags when i used fb:serverFBml tag also. Please help me regarding this..


    • mahmud ahsan
      mahmud ahsan
      September 28, 2010 at 4:05 pm

      You have to load javascript sdk to parse XFBML tags.

  • Andrei
    November 18, 2010 at 12:24 am

    hey, thanks for the code.
    I have one question though: when I call the function, what does $facebook stand for?

    • mahmud ahsan
      mahmud ahsan
      November 18, 2010 at 12:16 pm

      Checkout my other tutorial to know what is $facebook.

  • manu
    December 9, 2010 at 2:41 pm

    I am trying to embed flash in php… will i get the source of videos that are published or shared by my friends that saw in my updates using facebook api?