当用户接受我的应用程序并在我的网站上阅读故事时,我正在使用 $facebook->api 自动发布故事。这一切都很好,但问题是当他刷新页面或重新访问页面时,相同的故事/链接会重新发布在他的墙上!我怎样才能为一个用户发布一次故事!我在wordpress中这样做!
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>';
}