我正在尝试打印出用户的Facebook好友列表。但是,当我使用下面的代码时,我不断收到错误:Uncaught OAuthException:必须使用活动访问令牌来查询有关当前用户的信息(即使我包含Auth Token)。不确定有什么问题。在此先感谢您的帮助。
<?php
}
else{
if (!class_exists('FacebookApiException')) {
require_once('./src/facebook.php' );
}
$facebook = new Facebook(array(
'appId' => $appId,
'secret' => $appSecret,
));
$fbuser = $facebook->getUser();
echo $fbuser;
$friends = $facebook->api('me/friends');
foreach ($friends as $key=>$value) {
sort($value);
foreach ($value as $fkey=>$fvalue) {
//I've tried this...
echo '<img src="https://graph.facebook.com/'.$fvalue[id].'/picture">';
//and I've tried this with the Auth Token (still not working).
echo '<img src="https://graph.facebook.com/'.$fvalue[id].'/friends?fields=picture&access_token=<access token>" width="50" height="50" title="'.$fvalue[name].'" />';
}
}
echo $_SESSION['user_name'];
echo '<img src="https://graph.facebook.com/'.$fbuser.'/picture">';
echo '<a href="?logout=1">Log Out</a>';
}
?>