Thanks Derek, your first link fixed the problem. The amount of time I have spent sifting through rubbish posts about the subject far outweighs the length of time it took me to post this question and looks like it was worth it!
–
TomDec 29 '11 at 17:40

And for anyone who comes across this question - adding FB.api('/me', function(response) { to the login fixed it.
–
TomDec 29 '11 at 17:42

The above code explanation is that if getUser() returns a 0 then we need to redirect with $facebook->getLoginUrl() to a page where the user will accept the application and get permissions, then getUser() will work if the user accepts otherwise you'll get 0 again.ù
–
dendiniFeb 14 '14 at 9:39

Came across a situation where getUser() was returning 0 when it really shouldn't be, the application was still sandboxed. Turns out the user hadn't accept the request to be developer of the application.

I had same issue, After long time of trying to figure out what the issue is,
I found that you need access token to get user ID.
To get access token form the signed_request, user must authorize (to get permissions) you app firstly.
I hope this will help