开发者

Returning a list of user friends in facebook graph api using php

开发者 https://www.devze.com 2023-04-10 18:18 出处:网络
I\'m having trouble (yet again) with returning a list of friends for a specific user开发者_StackOverflow中文版. This is the code:

I'm having trouble (yet again) with returning a list of friends for a specific user开发者_StackOverflow中文版. This is the code:

   $friends = $facebook->api('/me/friends');
 echo $friends;  

However, it does not display anything on the page at all. Does anyone know how to fix this?


Yup, you have to provide active access token. If I remember correctly you need special permission to see user's friend list too.

$token = $facebook->getAccessToken();  $friends = $facebook->api('/me/friends', 
                          'GET', 
                           array (
                             'access_token' => $token));

Update: Friends lists are included with the basic permissions. The Facebook API reference says:

Read

You can read the list of a User's friends by issuing an HTTP GET to /PROFILE_ID/friends with any valid access_token of the current session user. For example:

https://graph.facebook.com/me/friends

0

精彩评论

暂无评论...
验证码 换一张
取 消