大家好 :) 我希望我的 wordpress 博客在我的访问者时间轴上自动共享,所以我将此代码添加到 header.php 的顶部。问题在于'link' => '<?php the_permalink(); ?>
which 变成了错误。每当我将 url 放在纯 txt 中时,它都会起作用,即http://seoshqip.com,但我希望将访问者正在浏览的永久链接张贴在他的墙上。演示站点是http://seoshqip.com。谁能帮帮我?
<?php
require_once('php-sdk/facebook.php');
$config = array(
'appId' => '137338253107187',
'secret' => '13d3be5549ff2f2e1c793b5270a3a487',
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
$access_token = $facebook->getAccessToken();
if($user_id) {
try {
$ret_obj = $facebook->api('/me/feed', 'POST',
array(
'link' => '<?php the_permalink(); ?>' ,
'message' => 'Posting with the PHP SDK!'
));
} catch(FacebookApiException $e) {
$login_url = $facebook->getLoginUrl( array(
'scope' => 'publish_stream'
));
header("Location: $login_url");
error_log($e->getType());
error_log($e->getMessage());
}
} else {
$login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream' ) );
header("Location: $login_url");
}
?>