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 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!