2

So this is what I'm doing- I am using facebook login for my site using the php-sdk. I have given the redirect URI to a function that checks if the user exists in my database, if not create the user, then redirect to my home page.

redirect uri is http://somedomain.com/login/check_fb_login
check_fb_login will check if user exists in db, if not create

However, my check_fb_login is not getting the value of the userID.

 $facebook->getUser() is getting 0

Why is this so? getUser should return a value because the user has already been authenticated by facebook right?

Ninja
  • 5,082
  • 6
  • 37
  • 59

3 Answers3

2

it might be a bug, see http://developers.facebook.com/bugs/223499947703278

but also search for facebook->getUser() returns 0 on stackoverflow, there are a lot of topics about it so it could be something else.

alexl
  • 1,842
  • 1
  • 14
  • 15
1

Check you are initializing $this->facebook object (by printing appId) or not.

And also See this links:

link1

link2

link3

link4

Community
  • 1
  • 1
Somnath Muluk
  • 55,015
  • 38
  • 216
  • 226
0

I had the same problem, and solved it by adding a full url. So instead of

http://somedomain.com/login/check_fb_login

try

http://somedomain.com/login/check_fb_login/index.php

I also made sure that this was the same url in Site URL: and Mobile Site URL: on my Facebook Developers app page, and in the connection code:

$app_id     = "my_id";
$app_secret = "my_secret";
$site_url   = "http://somedomain.com/login/check_fb_login/index.php";
Shaun
  • 2,043
  • 3
  • 27
  • 36