通过页面选项卡第一次查看时没有签名请求
我的页面选项卡有问题。 当我第一次通过页面选项卡访问应用程序时(例如注销、更改浏览器、删除所有cookie),我没有收到signed_request。 这是我的代码(部分)(我使用的是最新的 PHP SDK):
require_once ('facebook.php');
$app_id = "xxx";
$app_secret = "xxx";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
$page_id = $signed_request['page']['id'];
我第一次打开页面选项卡时 $page_id 为空。当我再次单击页面选项卡时,一切正常并且 $page_id 被填充。
我做错了什么? 我在 stackoverflow 上找到了可能的解决方案,但它们对我不起作用: “signed_request for Canvas”已启用,我的页面选项卡 URL 以“tab.php”结尾。
多谢!
I'm having a problem with my page tab.
When I access the app via the page tab the first time (e.g. logout, change browser, delete all cookies), I don't get the signed_request.
Here's (a part of) my code (I'm using the newest PHP SDK):
require_once ('facebook.php');
$app_id = "xxx";
$app_secret = "xxx";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
$page_id = $signed_request['page']['id'];
$page_id is empty the first time I open the page tab. When I click the page tab again, everthing's fine and $page_id gets populated.
What am I doing wrong?
I found possible solutions on stackoverflow, but they don't work for me:
"signed_request for Canvas" is enabled and my page tab url ends with "tab.php".
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我明白了。
我包含了一个文件来获取用户的时区(基于机器时间,而不是 facebook)。
在此文件中,有:
window.location = "
这可能会导致 facebook 在第一次访问时丢失signed_request。
删除包含的 php 文件可以解决问题...现在我只需要找到一种方法使时区在 facebook 中工作。
Ok, I figured it out.
I included a file to get the user's timezone (based on the machine time, not facebook).
In this file, there's :
window.location = "<?php echo $_SERVER['PHP_SELF'];?>
This probably causes facebook to lose the signed_request on first visits.
Deleting the included php-file fixes the problem... now I only have to find a way to make the timezone work within facebook.