First im getting the "login url":
if (!$facebook->getUser())
{
$login_url = $facebook->getLoginUrl(array(
'scope' => 'publish_stream'
));
}
And redirect to it, if the user not login it requests him to log in, If the user need to authorize the App, it will request him to do that as well.
The problem is that after the user authorized the App and redirected to my redirect_uri, I still can get his token in order to fetch information about him. This:
$facebook->getAccessToken()
Returns the App access token (the one with the pipe in the middle) and this: $facebook->getUser() return 0. and im ending with an endless loop which requesting the login url (first time it will request to authorize my APP) an redirect to my redirect_uri which requesting it again because $facebook->getUser() returning 0.
And the funny part is: When i use this code on other server (located elsewhere in the world) it works. And when i try this on other server (in even other location in the world) it works only 60% of the time.
Where is the problem? in my code? in my server? in Facebook?
Thanks !!!