$facebook->getUser() 在转移到新主机后返回 0
我正在使用 Facebook PHP SDK 3.1.1。这段代码在我以前的主机上运行得很好。我刚刚将其移至 BlueHost,即使用户已经登录,$user 的值也始终为 0:
$facebook = new Facebook(array(
'appId' => FACEBOOK_APIKEY,
'secret' => FACEBOOK_SECRET_KEY,
));
$user = $facebook->getUser();
知道为什么会发生这种情况吗?
I'm using Facebook PHP SDK 3.1.1. This code works fine for me on my previous hosting. I've just moved it to BlueHost and the value of $user is always 0 even when user already logged in:
$facebook = new Facebook(array(
'appId' => FACEBOOK_APIKEY,
'secret' => FACEBOOK_SECRET_KEY,
));
$user = $facebook->getUser();
Any idea why this can happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
getUser()
函数使用$_REQUEST['signed_request'])
全局变量。由于您说您最近切换了托管帐户,因此服务器可能配置为关闭
$_REQUEST
或以某种方式覆盖它。您可以检查这些 php.ini 变量,因为它们会影响
$_REQUEST
:看到这些变量在您的模板中执行
phpinfo();
,它将打印出来所有必要的信息。http://php.net/manual/en/function.phpinfo.php
否则,您可能需要联系您的托管提供商并询问
$_REQUEST
全局变量,看看是否可以使用它。The
getUser()
function uses the$_REQUEST['signed_request'])
global.And since you said you recently switched hosting accounts, it is possible that the server is configured either to turn off
$_REQUEST
or somehow override it.You can check these php.ini variables, because they affect
$_REQUEST
:The see these variables do
phpinfo();
in your template, which is going to print out all the necessary information.http://php.net/manual/en/function.phpinfo.php
Otherwise, you might need to contact your hosting provider and ask about the
$_REQUEST
global, to see if you can use it.