如何在 Facebook 上创建粉丝/点赞门?
我正在尝试创建一个简单的扇形/类似门。您可以在其中为非粉丝指定一项内容,为粉丝指定其他内容(如果他们按下了“喜欢”按钮)。但是,当我在页面选项卡中运行该页面时,它不会返回签名的请求,因此我无法弄清楚如何执行此操作。有人可以发布教程,或者解决这个问题吗?此时我得到以下代码:
index.php
<?php
require dirname( __FILE__ ) . '/../api/facebook.php';
// Create our application instance
// (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => '112458478872227',
'secret' => 'X',
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Home</title>
</head>
<body>
<?php
if ( $signed_request['page']['liked'] )
{
echo 'A fan';
}
else
{
echo 'Not a fan yet.';
}
?>
</body>
</html>
链接:
http://www.facebook.com/talkieslifestylemagazine?sk=app_112458478872227
Faceook 应用程序:
页面选项卡 页面
- 选项卡名称:主页
- 选项卡 URL:http:// apps.talkiesmagazine.eu/facebook/home
- 安全页面选项卡 URL:空
- 页面选项卡编辑 URL:空
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看起来原来的海报改用了 Wildfire 的类似门应用程序。但无论如何...
您的服务器在脚本运行之前正在执行重定向。如果您将代码放在 http://apps.talkiesmagazine.eu/facebook 等文件夹中/home/index.php - 但您指定http://apps.talkiesmagazine.eu/facebook/home 作为您的网址 - 网络服务器将看到 http://apps.talkiesmagazine.eu/facebook/home 是一个文件夹并重定向到 http://apps.talkiesmagazine.eu/facebook/home/。该重定向不会保留携带签名请求的 POST 数据。您可以查看是否将 http://apps.talkiesmagazine.eu/facebook/home 添加到您的浏览器,它被重定向到 http://apps.talkiesmagazine.eu/facebook/home/ 。
将标签页网址更改为 http://apps.talkiesmagazine.eu/facebook/home/ 将修复它。
但是,Facebook 要求您设置服务器以通过 https 安全地为您的应用程序提供服务,并将安全选项卡 URL 设置为该 URL。您的
安全页面选项卡 URL
为空,因此也需要进行更改才能拥有功能齐全的选项卡。It looks like the original poster switched to using Wildfire's like gate app. But anyway...
Your server is doing a redirect before your script is run. If you put your code in a folder such as http://apps.talkiesmagazine.eu/facebook/home/index.php - but you specify http://apps.talkiesmagazine.eu/facebook/home as your url - the webserver will see that http://apps.talkiesmagazine.eu/facebook/home is a folder and redirect to http://apps.talkiesmagazine.eu/facebook/home/. That redirect doesn't preserve the POST data which carries the signed request. You can see if you put http://apps.talkiesmagazine.eu/facebook/home in your browser, it is redirected to http://apps.talkiesmagazine.eu/facebook/home/.
Changing your tab url to http://apps.talkiesmagazine.eu/facebook/home/ will fix it.
However, Facebook requires that you have your server setup for securely serving your app over https and set the secure tab url to that url. You have the
Secure Page Tab URL
empty, so that would need to be changed as well to have a fully functional tab.不确定为什么未向您显示已签名的请求。它仍在工作。
代码: http://fbmhell.com/2011/06/ facebook-like-gating-in-iframe-tabs/
页面选项卡:http://www.facebook.com/snipe.net?sk=app_207328155971716
也许是迁移设置中的某些内容您必须选中/取消选中?他们在过去几个月里做出了一些改变。
Not sure why the signed request isn't showing for you. It's still working.
code: http://fbmhell.com/2011/06/facebook-like-gating-in-iframe-tabs/
page tab: http://www.facebook.com/snipe.net?sk=app_207328155971716
Maybe it's something in the migration settings that you have to check/uncheck? They've made some changes over the past few months.
让我们试试这个:
1,使用以下代码在应用程序根目录上创建一个名为 index.php 的简单 php 文件:
2,转到您的应用程序选项卡,然后检查出现的内容。
2a,如果仅显示“POST check”消息,请检查应用程序设置页面上的应用程序 URL。可能忘记用 / 关闭 url,或者某处有空格。
2b,如果“POST check”消息后面跟着一个数组结构,则说明您的 SDK 实现有问题。
Let's try this:
1, Create a simple php file on the app root named index.php with the following code:
2, Go to your app tab, and check what is come up.
2a, If the "POST check" message only, check the app URL on the app settings page. May be forget to close the url with / or there is a space somewhere.
2b, If the "POST check" message followed by an array structure, something wrong with your SDK implementation.
从外观上看,您的示例正在使用 Facebook PHP SDK。如果您想要更简单且相对直接的实施方式,请查看此Facebook Fan /就像 GitHub 上的 Gate 一样。
我过去在很多 Facebook 标签上使用过它,而且效果很好。还有一个“JavaScript 设置”分支,其中包含 js sdk 和应用程序配置设置并准备就绪。
Your example is using the Facebook PHP SDK by the looks of it. If you want something a bit simpler and relatively straight forward to implement, then take a look at this Facebook Fan / Like Gate over on GitHub.
I've used it on a bunch of Facebook tabs in the past and it's served me well. There's also a 'JavaScript setup' branch with the js sdk and application config setup and ready to go.