当用户接受我的应用程序并在我的网站上阅读故事时,我使用$ 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>';
}
答案 0 :(得分:1)
怎么样:
创建一个db表,如:
[user_article_posted]
user_article_posted_id
user_id
article_id
每次用户阅读(加载)文章时,如果通过Facebook登录,请检查是否有user_id / article_id记录的组合。
user_id也可以是fbuser,具体取决于您的结构。