First of all, to get this out of the way, I\'ve spent hours looking through answers to this question here on StackOverflow, and tried to solve it on my own, but it just isn\
I think you need to setAccessToken() before calling any facebook methods, even when the use has authorized your app and is logged in.
I had the same problem. It turned out i was using localhost. Though the allow access dialog appeared on facebook and i was redirected back to my web page, getUser still returned zero.
My Solution
Once i uploaded my code and tested it online, reasonable facebook errors appeared then had to change my "App Domains" and "Site Url" to relevant values for my online test website NOT localhost. And then it worked!
In base_facebook.php add the following 2 lines under $CURL_OPTS:
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2
Which makes it...
public static $CURL_OPTS = array(
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'facebook-php-3.2',
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2
);
I'm not sure how much of a security issue this is, but it makes the Login with Facebook work, so there you have it.
EDIT: New SDK released which fixes this problem: https://github.com/facebook/facebook-php-sdk
I had this issue, which turned out to be a corrupt certificate. I think I had autocrlf turned on in Git. I don't know if that fixed it or not, but blowing away my whole repo and re-cloning from source caused this problem to clear right up!