简体   繁体   中英

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

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?

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 :

  • variables_order
  • request_order

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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