PHP-SDK重定向过多 [英] PHP-SDK too many redirects
问题描述
我正在为Facebook使用 PHP-SDK ,并举例说明在我的本地主机上工作。然而,当在服务器上构建脚本时,脚本保持相当繁忙,从脚本重定向到Facebook并返回。 (错误:Fout 310(net :: ERR_TOO_MANY_REDIRECTS):)
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):)
似乎还有更多的人遇到这个问题( here , here ,这里,这里)。虽然,我找不到明确的答案出了什么问题。
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.
重定向到Facebook(回复302):
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#_=_
重定向到mydomain(响应302):
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#_=_
创建此问题的部分代码
...
$facebook = new FacebookApi(array(
'appId' => $app->getProperty('apiKey'),
'secret' => $app->getProperty('secretKey'),
));
$user = $facebook->getUser();
if (!$user) {
header('location: ' . $facebook->getLoginUrl());
exit;
}
...
更新:
我排除了它的服务器设置。我能够在该服务器上运行原始示例脚本。
I ruled out that its a server setting. I was able to run the original example script on that server.
推荐答案
在您的应用设置中重新检查您的应用秘密
https://developers.facebook.com/apps 否则转储会话
Recheck your app secret
in your app settings https://developers.facebook.com/apps otherwise dump the session
<?php print_r($_SESSION); ?>
并退出令牌, 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.
这篇关于PHP-SDK重定向过多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!