我使用$ facebook-> api自動發佈故事,當用戶接受我的應用程序並在我的網站上讀取故事。這一切都可以正常工作,但問題是當他刷新頁面或重新訪問頁面時,同樣的故事/鏈接會重新張貼在他的牆上! 如何爲一位用戶發佈故事一次! 我在wordpress中這樣做!Facebook應用程序發佈故事一次
include_once("fb_config.php");
//Setup Facebook post url and login url
$post_url = '/'.$fbuser.'/feed';
$loginUrl = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0,
'scope' => $fbPermissions,
'redirect_uri'=>$homeurl
));
//Setup the message to be posted on users wall
$thumbnail = wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'thumbnail'));
$description = my_excerpt($post->post_content, $post->post_excerpt);
$description = strip_tags($description);
$description = str_replace("\"", "'", $description);
$p_title = html_entity_decode(get_the_title(), ENT_NOQUOTES, 'UTF-8');
$news = array(
'message' => '',
'name' => htmlspecialchars_decode($p_title),
'link' => get_permalink($post->ID),
'caption' => get_bloginfo ('description'),
'description' => $description,
'picture' => $thumbnail
);
if ($fbuser) {
try {
$postResult = $facebook->api($post_url, 'post', $news);
}
catch (FacebookApiException $e) {
echo '<script>top.location.href = "'.$loginUrl.'"</script>';
}
}else{
echo '<script>top.location.href = "'.$loginUrl.'"</script>';
}
你可以在這裏發佈一些代碼,尤其是自動發佈部分? – mallix
e dited原帖 –