Facebook Fan Gate - 展示“揭秘”内容
我正在尝试向我的页面添加粉丝门,并且我可以显示“喜欢前”的内容,但在我喜欢该页面后 - 喜欢后的内容不会显示。无论我是否喜欢该页面,它都会显示相同的预赞内容。
这是我在 index.php 文件中使用的代码...
require 'facebook.php';
$app_id = "myappid";
$app_secret = "myappsecret";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
$page_id = $signed_request["page"]["id"];
$page_admin = $signed_request["page"]["admin"];
$like_status = $signed_request["page"]["liked"];
$country = $signed_request["user"]["country"];
$locale = $signed_request["user"]["locale"];
// If a fan is on your page
if ($like_status) {
$a = file_get_contents("dolike.html");
echo ($a);
} else {
// If a non-fan is on your page
$a = file_get_contents("dontlike.html");
echo ($a);
}
?>
我看过六个示例,它们本质上都是相同的(有一些变体,有些使用图像而不是 html,有些在同一页面中使用 html) ,但都没有显示类似帖子的内容。
我从代码中删除了应用程序 ID 和密钥,尽管我确实拥有它们并且一直在使用它们。
任何帮助都会很棒。
I'm trying to add a fan gate to my page, and I can get the "pre-like" content to show, but after I like the page - the post-like content isn't showing up. It shows the same pre-like content, regardless of whether I like the page or not.
This is the code I'm using in my index.php file...
require 'facebook.php';
$app_id = "myappid";
$app_secret = "myappsecret";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
$page_id = $signed_request["page"]["id"];
$page_admin = $signed_request["page"]["admin"];
$like_status = $signed_request["page"]["liked"];
$country = $signed_request["user"]["country"];
$locale = $signed_request["user"]["locale"];
// If a fan is on your page
if ($like_status) {
$a = file_get_contents("dolike.html");
echo ($a);
} else {
// If a non-fan is on your page
$a = file_get_contents("dontlike.html");
echo ($a);
}
?>
I've looked at half-dozen examples, and they're all essentially the same (with a few variants, some use images over html, some use the html in the same page), but none of them show the post-like content.
I removed the app id and secret from the code, though I do have them and have been using them.
Any help'd be awesome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:)
编辑:
或者尝试这个没有 FB PHP-SDK 的版本,这是我用于 fangating 的解决方案,所以我不需要用户使用整个 PHP-SDK
Try this :)
EDIT:
Or try this version without the FB PHP-SDK, this is the solution I use for fangating so i don't need the user the whole PHP-SDK