我应该如何使用PHP中的Graph API获取Facebook用户朋友列表及其个人资料图片?



我正在使用此代码来获取用户朋友的列表。对于个人资料图片,我找不到任何参考,如果您知道该过程,请指导

$facebook = new Facebook($config);
$user_id = $facebook->getUser();
$iLimit=99;
if($user_id) {
     // We have a user ID, so probably a logged in user.
     // If not, we'll get an exception, which we handle below.
     try {
       $user_profile = $facebook->api('/me','GET');
      echo"<h3>";
echo 'Name: ' . $user_profile['name'];
echo"</h3>";
$profile_pic =  "http://graph.facebook.com/".$user_id."/picture";
echo "<img src="" . $profile_pic . "" />"; 
$user_friends = $facebook->api('/me/friends', 'GET' );
print_r($user_friends);            //Given NULL Value 
echo "</pre>";

返回空值

请参考脸书图 API 文档https://developers.facebook.com/docs/graph-api/reference/friend-list/这是带有教程的代码http://www.sanwebe.com/2011/10/facebook-friends-list-pagewise-with-php希望对您有所帮助!

最新更新