问题
I'm trying to add a facebook login to my site but the problem is that the facebook function "getUser" only works sometimes. Half the time I'll get the user's facebook id from it, but half the times I won't.
Is there a delay somewhere? How can I fix this?
My if facebook_uid set
fails and it all ends up in a big mess. :(
Facebooks getSession
never fails though. All the above happens when a facebook session is correctly initiated.
Please help!
Here's part of my code:
$facebook = new Facebook(array('appId' => '123','secret' => '789','cookie' => true,));
$facebook_session = $facebook->getSession();
if ($facebook_session) $_SESSION['facebook_uid'] = $facebook->getUser();
来源:https://stackoverflow.com/questions/5951356/facebook-login-getuser-not-working-properly