好吧我无法弄清楚这里的问题是什么...... 我正在尝试将用户墙作为页面发布。 我一直在 string(53)“(#200)目标用户尚未授权此操作” 这是完整的代码
session_start();
$config = array();
$config['appId'] = 'xxxxxxxxx';
$config['secret'] = 'xxxxxxxx';
$config['fileUpload'] = false; // optional
$facebook = new Facebook($config);
$params = array(
'scope' => 'user_birthday, user_likes, publish_actions, email, publish_stream, manage_pages',
'redirect_uri' => 'xxxxxxxxxxxxx'
);
$loginUrl = $facebook->getLoginUrl($params);
$logoutUrl = $facebook->getLogoutUrl();
$user_id = $facebook->getUser();
?>
<html>
<head></head>
<body>
<?
if($user_id) {
try {
echo 'Please <a href="' . $logoutUrl . '">logout.</a>';
$user_profile = $facebook->api('/me','GET');
echo "Name: " . $user_profile['name'];
$access_token = $facebook->getAccessToken();
$page_id = 'xxxxxxxxxx';
$result = $facebook->api("/me/accounts");
foreach($result["data"] as $page) {
if($page["id"] == $page_id) {
$page_access_token = $page["access_token"];
break;
}
}
if( !empty($page_access_token) ) {
$args = array(
'access_token' => $page_access_token,
'message' => "Hello Billy!!"
);
$post_id = $facebook->api("/{$user_profile['id']}/feed","post",$args);
} else {
}
// $page = $facebook->api("/{$page_id}",'GET');
} catch(FacebookApiException $e) {
error_log($e->getType());
error_log($e->getMessage());
?><pre><?var_dump($e->getMessage())?></pre><?
}
} else {
///
echo 'Please <a href="' . $loginUrl . '">login.</a>';
}
?>
</body>
</html>
答案 0 :(得分:2)
只是为了确认,您是要发布到用户的个人资料或时间轴,并让帖子显示为“发件人”作为发件人?
这是不可能的,也从来没有。 API根本不支持它。