我无法理解这个问题。我按照https://developers.facebook.com/docs/php/howto/postwithgraphapi/上的教程进行了操作。
但是,我无法发布指向用户墙的链接。以下是我的代码:
<?php
error_reporting(E_ALL); ini_set('display_errors', 'On');
require 'src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'XXX',
'secret' => 'XXXXX',
));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if($user) {
try {
$ret_obj = $facebook->api('/me/feed', 'POST',
array(
'link' => 'www.example.com',
'message' => 'Posting with the PHP SDK!'
));
echo '<pre>Post ID: ' . $ret_obj['id'] . '</pre>';
// Give the user a logout link
echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';
} catch(FacebookApiException $e) {
$login_url = $facebook->getLoginUrl(array(
'scope' => 'publish_stream'
));
echo 'Please <a href="' . $login_url . '">login.</a>';
error_log($e->getType());
error_log($e->getMessage());
}
} else {
// No user, so print a link for the user to login
// To post to a user's wall, we need publish_stream permission
// We'll use the current URL as the redirect_uri, so we don't
// need to specify it here.
$login_url = $facebook->getLoginUrl(array('scope' => 'publish_stream'));
echo 'No user...Please <a href="' . $login_url . '">login.</a>';
}
?>
我已启用错误报告,但无法显示任何错误。输出总是:
“请登录。”
当我点击链接时,从Facebook重定向后,再次显示相同的消息。