我使用$ 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原帖 –