drbxr86044 2012-10-25 09:34
浏览 95
已采纳

PHP-SDK有太多重定向

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.

  • 写回答

1条回答 默认 最新

  • douzhunlan5930 2012-11-11 23:21
    关注

    Recheck your app secret in your app settings https://developers.facebook.com/apps otherwise dump the session

    <?php print_r($_SESSION); ?>
    

    And lint the token returned https://developers.facebook.com/tools/debug

    Pretty sure either the token is mangled or the secret.

    If not, it's in code you haven't shown.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序