我被这个问题困扰了一段时间了。我正在尝试检索我的朋友列表(谁正在使用这个应用程序,当然)。SDK版本为3.2.3。代码确实从我的个人资料中提取信息,但没有从我的朋友的个人资料中提取任何信息。虽然我使用的范围权限参数与我的登录。以下是我的index.php文件:
require_once('facebook.php');
$config = array(
'appId' => 'xxxx',
'secret' => 'xxxx'
//'allowSignedRequest' => false
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
<html>
<head></head>
<body>
if($user_id) {
try {
$user_profile = $facebook->api('/me','GET');
echo "<pre>";
print_r($user_profile); //prints my profile
echo "</pre>";
foreach ($user_profile["data"] as $friend) {
echo $friend['id'];
echo $friend['name'];
}
echo '<br><a href=' . $facebook->destroySession() . '>Logout</a>';
} catch(FacebookApiException $e) {
}
} else {
$params = array(
'scope' => 'public_profile, user_friends, email',
);
$login_url = $facebook->getLoginUrl($params);
echo 'Please <a href="' . $login_url . '">login.</a>';
}
</body>
</html>
How can i just print my friend's list? (those friends whose permission i have!)
改变
$user_profile = $facebook->api('/me','GET');
$user_profile = $facebook->api('/me?fields=id,first_name,last_name,friends','GET');
例如。