我为用户提供了一些特殊功能,它们向他们的 Facebook 发送关于我的服务的帖子,那里有很多脚本可以检测到“喜欢”,然后我们可以为用户解锁一些功能(喜欢解锁),但我希望用户发布帖子然后解锁该功能,而不仅仅是喜欢。
使用我的 FB like 按钮,在喜欢它之后,它会自动打开一个小窗口,以便他们可以发布一些东西,我如何检测 POSTS 而不仅仅是 Like?
谢谢
但我希望用户发布帖子然后解锁该功能
这将违反Facebook 平台政策:
四。应用程序集成点,
1.) 您不得激励用户使用(或在使用 Facebook 社交渠道后屏蔽内容),或暗示激励与使用我们的渠道直接相关。
<?php
session_start(); //start PHP session
session_regenerate_id(true); //Generated new session id
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Project</title>
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
<div id="tweet_content" class="locked_ct"><h5>Tweet to Unlock this Content</h5>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="saaraan">Tweet</a>
</div>
<script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script>
<script type="text/javascript">
//All event bindings must be wrapped within callback function
twttr.ready(function (twttr) {
//######## trigger when the user publishes his tweet
twttr.events.bind('tweet', function(event) {
/*
To make locked items little more private, let's send our base64 encoded session key
which will work as key in send_resources.php to acquire locked items.
*/
var data = {unlock_key : '<?php echo base64_encode(session_id());?>'};
//Load data from the server using a HTTP POST request.
$.post("send_resources.php", data, function(data)
{
//Append unlocked content into div element
$('#tweet_content').html(data);
}).error(function(xhr, ajaxOptions, thrownError) {
//Output any errors from server.
alert( thrownError);
});
});
});
</script>
</body>
</html>
<?php
session_start(); // session start
//retrive base64 encoded post variable and compare it with session id.
if (isset($_POST["unlock_key"]) && base64_decode($_POST["unlock_key"])===session_id())
{
//user unlocked item by tweeting.
echo "Congratulations! You just unlocked this text by Tweeting!";
}else{
//Output HTTP errors
header('HTTP/1.1 500 Oops! something went wrong...');
exit();
}
?>
那是推特的,但它可能可以适应脸书。