我有一些奇怪的问题构建Facebook的iframe应用程序。该应用程序似乎陷入了无限循环转到应用程序页面。Facebook的PHP SDK 3.1.1“错误验证访问令牌”后去转到应用页
用户在转到应用程序页面授权应用程序并返回到应用程序后,/ me api调用将引发“验证访问令牌的错误”异常。我检查并且在签名请求中有一个有效的访问令牌(使用facebook访问令牌调试工具进行测试)。我试图用setAccessToken()方法设置失败。 getUser()方法成功返回用户标识,但它仍挂在/ me api调用上。
这不会发生在每个浏览器中,我只是在Chrome中看到它,有时并不清晰。我使用P3P标题在IE中修复了它。它在Firefox中正常工作。
我几乎卡住了,我头发拔出,所以任何想法都欢迎。非常感谢。
完整的错误消息:“验证访问令牌的错误:您无法访问该应用程序,直到您登录到www.facebook.com并按照给出的说明进行操作。”
下面的代码。
$this->_facebook = new Facebook(
array(
'appId' => $this->_config['appId'],
'secret' => $this->_config['secret'],
'cookie' => true,
'fileUpload' => true
)
);
$this->_signedRequest = $this->_facebook->getSignedRequest();
// Doing something with signed request, not FB related
$this->_userId = $this->_facebook->getUser();
if($this->_userId) {
try{
// At this line the "Error validating access token" error shows up
$this->_user = $this->_facebook->api('/me');
// Some more irrelevant code here
} catch (Exception $e){
$this->_facebook->destroySession();
$this->_facebookLogin(false);
}
} else {
$this->_facebook->destroySession();
$this->_facebookLogin(false);
}
// The _facebookLogin method
public function _facebookLogin($perms = 'email,user_birthday,publish_stream,video_upload'){
$data = array(
'fbconnect' => 0,
'redirect_uri' => 'aredirecturl.com'
);
if(!empty($perms)) {
$data['scope'] = $perms;
}
echo '<script type="text/javascript">window.top.location.href = "'.$this->_facebook->getLoginUrl($data).'";</script>';
exit;
}
你可以把你的完整代码(例如在这个代码中'公共函数_facebookLogin'是错误的 – 2012-03-09 20:38:34
我面临同样的问题,铬也是如此。@Cazacu弗拉德如果你找到解决方案,请在这里发帖谢谢 – 2012-09-09 00:24:57