2

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 !!!

4

2 回答 2

1

尝试$facebook->getAccessTokenFromCode($_GET['code'])改用。

于 2012-10-31T11:42:07.110 回答
0

我有时也遇到过这个问题。结果是,在那段时间里,我将 Facebook 用作同一应用程序的页面,而不是像我通常的个人资料那样使用。因此,每当您遇到此问题时,您都可以检查以确保您使用 Facebook 作为用户个人资料,而不是任何页面

我希望这至少可以为将来的某人节省一些挫败感,尽管您的问题已解决,但还是回答了。

于 2013-01-06T02:50:01.277 回答