简体   繁体   中英

facebook friends list getting

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_friends = $facebook->api('/me/friends');

result:

( [data] => Array ( ) [summary] => Array ( [total_count] => 46 ) )

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>';
    }

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM