facebook friends list getting

前端 未结 2 1970
悲哀的现实
悲哀的现实 2021-01-15 06:15

I want to get a list of friends with php. I got the necessary permissions, but I can not get a list of friends.

\'scope\' => \'email, user_friends\'

$user_fr

相关标签:
2条回答
  • 2021-01-15 06:32

    Here it is, buddy:

    <?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)
  • 2021-01-15 06:35

    The docs at https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids clearly states that the Graph API starting with v2.0 only returns the friends which also use the same app.

    In your case apparantly nobody of your friends actually uses that app, that's why the result array is empty.

    Please use the StackOverflow search the next time before you post a question which was posted here at least 100 times. Thanks.

    0 讨论(0)
提交回复
热议问题