Facebook 应用程序在 facebook.php SDK 中无法正常工作

发布于 2024-12-06 17:09:42 字数 1221 浏览 0 评论 0原文

不知道为什么这不起作用,并希望有人能够指出我正确的方向。

我有一个 Facebook 选项卡应用程序,应该根据用户是否“喜欢我们”来显示不同的内容。

require_once('src/facebook.php');
$app_id = "142214XXXXXXXX";  <--this is correct just hidden
$app_secret = "31275c8895XXXXXXXX";
$facebook = new facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
$like_status = $signed_request["page"]["liked"];

//just for testing (nothing shows up, nor does print($signed_request)
echo "the page is ".$page_id;

if(!$like_status){
echo "Please LIKE US to get this offer or check back on Sept 27";
} else {
echo '<img src="https://www2418.ssldomain.com/frightfurnace/SLOSSbogo.jpg"/><BR />
<a href="http://www.frightfurnace.com/coupon.asp">Printable Page</a>';
}

现在,我知道 SDK 已安装并正常工作,因为它确实适用于示例: http://www.frightfurnace.com/Facebook/example.php

我也做了确保我在 Facebook 应用程序设置中使用绝对网址。 我正在使用 http://www.frightfurnace.com/Facebook/coupon.php

与 SSL 相同。

任何想法,都有点阻碍。感谢所有帮助。

Not sure why this isn't working, and was hoping someone might be able to point me in the right direction.

I have a facebook tab app that should display different content depending on whether a user "likes us or not."

require_once('src/facebook.php');
$app_id = "142214XXXXXXXX";  <--this is correct just hidden
$app_secret = "31275c8895XXXXXXXX";
$facebook = new facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
$like_status = $signed_request["page"]["liked"];

//just for testing (nothing shows up, nor does print($signed_request)
echo "the page is ".$page_id;

if(!$like_status){
echo "Please LIKE US to get this offer or check back on Sept 27";
} else {
echo '<img src="https://www2418.ssldomain.com/frightfurnace/SLOSSbogo.jpg"/><BR />
<a href="http://www.frightfurnace.com/coupon.asp">Printable Page</a>';
}

Now, I know that the SDK is installed and working properly since it does work with the example:
http://www.frightfurnace.com/Facebook/example.php

I have also made sure I am using absolute urls in my Facebook App settings.
I am using
http://www.frightfurnace.com/Facebook/coupon.php

Same with SSL.

Any ideas, kinda stymied. All help appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

满栀 2024-12-13 17:09:42

很好地找到了答案,以防其他人需要它。

转到 Facebook 上的应用程序
https://developers.facebook.com/apps/

转到编辑设置

在左侧单击高级

signed_request对于画布:(启用它)
iframe 页面选项卡:(启用)

在“画布设置”下,确保“画布类型”为
iFrame

似乎对我有用。

Well found the answer in case anyone else needs it.

Go to your apps on Facebook
https://developers.facebook.com/apps/

Go to edit settings

On the left click Advanced

signed_request for Canvas: (Make it enabled)
iframe Page Tab: (enabled)

Under Canvas Settings make sure Canvas Type is
iFrame

Seemed to work for me.

隱形的亼 2024-12-13 17:09:42

另一件需要检查的事情是:选项卡/画布 url 必须与要求的完全相同。如果重定向到另一个页面,则不会发送签名请求和其他值。您可以使用浏览器嗅探器进行检查,如果对页面的调用响应 300(301/302 等)重定向,那么您需要更改其重定向到的内容。

示例:

https://example.com/ 可能需要是 https://www.example.com/(添加 www.,或删除 www.,具体取决于服务器的设置方式)

www.example.com/ 可能需要是 www.example.com/index.php (添加index.php,或正确的页面)。

检查您在 URL 中是否正确使用了 http:// 和 https://,并且 https:// 返回了有效页面。

Another thing to check: the tab/canvas url must be EXACTLY the same as required. If there is a redirect to another page, then signed request and other values will not be sent. You can check using a browser sniffer, if a call to the page responds with a 300 (301/302 etc) redirect, then you need to change to what it redirects to.

Examples:

https://example.com/ may need to be https://www.example.com/ (add www., or remove www. depending on how server is set up)

www.example.com/ may need to be www.example.com/index.php (add index.php, or the right page).

Check you are using http:// and https:// correctly in the URLs, and that https:// returns a valid page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文