Facebook PHP SDK: getUser returns 0 on first call
January 31, 2013 at 14:30
The problem: a facebook login doesn't always work. Although the user has authenticated the app, getUser returns 0.
So, the user clicks a LOGIN button and is being redirected to $facebook->getLoginUrl. Facebook forces the user to authenticate the app and afterwards redirects back to my page, to login.php to be exact. And this is where I call getUser, expecting to get the current user's facebookUserId. But this didn't work for a fresh user who hasn't been to my site just yet. What my script now did was to redirect back to getLoginUrl, which in turn redirects back to login.php and so on, which quickly makes the browsers stop and claim a "redirect error" (gee, I hope that's the right translation..). By the way, chrome is the first to give in, even before IE. Scary.