简体   繁体   English

$ facebook-> getUser()移至新主机后返回0

[英]$facebook->getUser() returns 0 after moving to new hosting

I'm using Facebook PHP SDK 3.1.1. 我正在使用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: 我刚刚将其移至BlueHost,即使用户已经登录,$ user的值也始终为0:

$facebook = new Facebook(array(
  'appId'  => FACEBOOK_APIKEY,
  'secret' => FACEBOOK_SECRET_KEY,
));

$user = $facebook->getUser();

Any idea why this can happen? 知道为什么会发生这种情况吗?

The getUser() function uses the $_REQUEST['signed_request']) global. getUser()函数使用$_REQUEST['signed_request'])全局$_REQUEST['signed_request'])

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. 而且,由于您说过最近切换了托管帐户,因此服务器可能配置为关闭$_REQUEST或以某种方式覆盖它。

You can check these php.ini variables, because they affect $_REQUEST : 您可以检查这些php.ini变量,因为它们会影响$_REQUEST

  • variables_order variables_order
  • request_order request_order

The see these variables do phpinfo(); 看到这些变量做phpinfo(); in your template, which is going to print out all the necessary information. 在您的模板中,它将打印出所有必要的信息。

http://php.net/manual/en/function.phpinfo.php http://php.net/manual/zh/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. 否则,您可能需要联系托管服务提供商并询问有关$_REQUEST全局信息,以查看是否可以使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM