I’m trying to implement facebook connect on my site but I have a very strange problem…
I’ve created a new library for all the tasks relating to authorization. Here is the FB login method:
function fb_login() {
$config = array(
'appId' => MY_ID,
'secret' => 'MY_SECRET',
'cookie' => true
);
$this->ci->load->library('facebook', $config);
$uid = $this->ci->facebook->getUser();
if ( $uid )
{
Here I am creating the session...
}
return $uid;
}
The problem is that the getUser() method always returns 0 after the user grants permissions and goes back to my site. If I redirect to facebook login url again (which will of course directly redirects back to my site as the app is already authorized) than is returns the correct value.
Any ideas why the getUser() method doesn’t work for the first time?