1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

I have a problem to get all friends who use the same app in PHP

Discussion in 'Facebook API' started by dangerfe, Feb 17, 2015.

  1. #1
    Hi everybody, I have a big problem to get the list of the friends who use the same app... I'm making a game (in canvas) and now, it's the time to integrate with facebook...

    I use this part of the script:

    
    $accessToken = $session->getAccessToken();
    $longLivedAccessToken = $accessToken->extend();
    
    $session = new \Facebook\FacebookSession($accessToken);
    
    // Check user's token is valid or not.
    $me = (new \Facebook\FacebookRequest( $session, 'GET', '/me/friends'))->execute()->getGraphObject(\Facebook\GraphUser::className());
    
    $result = $me->asArray();
    
    // Get user's friends
    $friends = $result['data'];
    
    // Converting classes to array
    foreach ($friends as $key => $value) {
        echo $friends[$key] = (array)$value;
        echo "|";
    }
    the page will echo:
    SEMrush
    Array|Array

    I don't understand why, the script repeat the Array two times because the user has 2 friends who use the same app...but I would like to retrieve the two UID of the friends... I don't know why doesn't works...

    thank you very much!!
     
    dangerfe, Feb 17, 2015 IP
    SEMrush
  2. webdeverman

    webdeverman Greenhorn

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    11
    #2
    Use Social. It is much easier and handles the conversion for you by only spitting out the result arrays. Plus it has and will have support for many other social media API's. Check it out here https://github.com/Karl-EdwardFPJeanMehu/Social
     
    Last edited: Mar 1, 2015
    webdeverman, Mar 1, 2015 IP