如何在PHP中使用Graph API获取Facebook用户好友列表及其个人资料图片?

时间:2016-04-25 12:50:53

标签: php facebook-graph-api

  

我正在使用此代码获取用户朋友的列表。如果你知道这个过程,我无法找到任何参考资料

$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>";\
  

返回空值

1 个答案:

答案 0 :(得分:0)