PHP-SDK too many redirects

Posted by Roel Veldhuizen on Stack Overflow See other posts from Stack Overflow or by Roel Veldhuizen
Published on 2012-10-25T09:34:45Z Indexed on 2012/11/07 11:01 UTC
Read the original article Hit count: 382

Filed under:
|

I'm using the PHP-SDK for Facebook and got the example to work on my localhost. However, when building a script on a server the script stays quite busy with redirecting from my script to facebook and back. (Error: Fout 310 (net::ERR_TOO_MANY_REDIRECTS):)

It seems that many more people have got this issue (here, here, here, here). Though, I can't find a clear answer what goes wrong.

Redirect to facebook (response 302):

https://www.facebook.com/dialog/oauth?client_id=166958180001271&redirect_uri=http%3A%2F%2Fdomain.com%2Fscripts%2FGateway.php%3Faction%3DAllowFacebookAccessAction%26app%3D14&state=0dbc178a375595da4751265a7147c01e#_=_

Redirect to mydomain (response 302):

http://domain.com/scripts/Gateway.php?action=AllowFacebookAccessAction&app=14&state=0dbc178a375595da4751265a7147c01e&code=AQD-dTeyns0OWpGb_PzfHxUy2iRmpc1XgP6Q24DDRX8MiRTE10lV-b-aSNIlOLVHk576vRs3H8Pf9n0kGwU827MrkzUCUoQGFGEQBkkOJnCy9zb6hZs7TVBsKL2iSuZIhDjLsCOPeKy3zfb37Q6LGhtMICCdB_IQAvU0uRvAkSAX8tdVJ65PEv8imx-2yvLaMoGJleZwKogh7m03vlhV8hJk#_=_

Part of the code that creates this issue

...            
    $facebook = new FacebookApi(array(
            'appId' => $app->getProperty('apiKey'),
            'secret' => $app->getProperty('secretKey'),
        ));
    $user = $facebook->getUser();
    if (!$user) {    
        header('location: ' . $facebook->getLoginUrl());
        exit;
    }
...

UPDATE:

I ruled out that its a server setting. I was able to run the original example script on that server.

© Stack Overflow or respective owner

Related posts about php

Related posts about facebook