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

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.

图片转代码服务由CSDN问答提供 功能建议

我正在使用 PHP-SDK 并得到了在我的localhost上工作的示例。 但是,在服务器上构建脚本时,脚本仍然很忙,从我的脚本重定向到Facebook并返回。 (错误:Fout 310(net :: ERR_TOO_MANY_REDIRECTS):)

似乎有更多人遇到此问题( here 这里 )。 虽然,我找不到明确的答案出了什么问题。

重定向到Facebook(响应302):

  https://www.facebook.com/dialog/oauth?client_id=166958180001271&  ; REDIRECT_URI = HTTP%3A%2F%2Fdomain.com%2Fscripts%2FGateway.php%3Faction%3DAllowFacebookAccessAction%26app%3D14&安培;状态= 0dbc178a375595da4751265a7147c01e#_ = _ 
   
 
 

重定向到mydomain(响应302):

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

这产生这一问题的代码的部分

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

更新: < 我排除了它的服务器设置。 我能够在该服务器上运行原始示例脚本。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题