Getting list of Facebook friends with latest API

后端 未结 10 1177
南旧
南旧 2020-12-07 18:06

I\'m using the most recent version of the Facebook SDK (which lets to connect to something called the \'graph API\' though I\'m not sure). I\'ve adapted Facebook\'s example

相关标签:
10条回答
  • 2020-12-07 18:32

    I think this is what you want:

    $friends = $facebook->api('/me/friends');
    
    0 讨论(0)
  • 2020-12-07 18:35

    in the recent version of facebook sdk , facebook has disabled the feature that let you access some one friends list due to security reasons ... check the documentation to learn more ...

    0 讨论(0)
  • 2020-12-07 18:36

    Using CodeIgniter OAuth2/0.4.0 sparks,

    in Auth.php file,

    $user = $provider->get_user_info($token);
    
    $friends = $provider->get_friends_list($token);
    print_r($friends);
    

    and in Facebook.php file under Provider, add the following function,

        public function get_friends_list(OAuth2_Token_Access $token)
        {
                $url = 'https://graph.facebook.com/me/friends?'.http_build_query(array(
                        'access_token' => $token->access_token,
                ));
                $friends = json_decode(file_get_contents($url),TRUE);
    
                return $friends;
        }
    
    prints the facebenter code hereook friends.
    
    0 讨论(0)
  • 2020-12-07 18:37

    header('Content-type: text/html; charset=utf-8');

    input in your page.

    0 讨论(0)
  • 2020-12-07 18:38

    Use FQL instead, its a like SQL but for Facebook's data tables and easily covers data query you'de like to make. You won't have to use all of those /xx/xxx/xx calls, just know the tables and columns you are intereseted in.

    $myQuery = "SELECT uid2 FROM friend WHERE uid1=me()";
    $facebook->api( "/fql?q=" . urlencode($myQuery) )
    

    Great interactive examples at http://developers.facebook.com/docs/reference/fql/

    0 讨论(0)
  • 2020-12-07 18:40

    This is live version of PHP Code to get your friends from Facebook

    <?php
        $user = $facebook->getUser();
    
    
        if ($user) {
            $user_profile = $facebook->api('/me');
            $friends = $facebook->api('/me/friends');
    
            echo '<ul>';
            foreach ($friends["data"] as $value) {
                echo '<li>';
                echo '<div class="pic">';
                echo '<img src="https://graph.facebook.com/' . $value["id"] . '/picture"/>';
                echo '</div>';
                echo '<div class="picName">'.$value["name"].'</div>'; 
                echo '</li>';
            }
            echo '</ul>';
        }
    ?>
    
    0 讨论(0)
提交回复
热议问题