-1

I am using this URL for authentication:

https://www.facebook.com/dialog/oauth?
     client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=email,read_stream

It is working fine, but when I use this code it always gives me a 0 value:

$user = $facebook->getUser();

What's wrong here?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Badal
  • 3,738
  • 4
  • 33
  • 60

1 Answers1

1

If that is returning 0, then the user is not logged into Facebook. The authentication just sends the user to the URL, if they don't grant the requested permissions (that is, don't login), then you won't be able to get the user ID.

You should also make sure you are using the latest PHP library (3.1). Older versions aren't compatible with the cookie structure Facebook currently uses, in which case the getUser call will always return 0.

You can also use JavaScript for authentication/request permissions which performs everything inline rather than redirecting to URLs.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Brent Baisley
  • 12,641
  • 2
  • 26
  • 39
  • i myself tried it i am allowing it it returns me to this url mysite.com?code=generated_code – Badal Dec 10 '11 at 16:19