我使用Zend_OpenId_Consumer提供OpenID访问,登录工作正常,但是当我调用verify()
时我收到了错误
`Wrong openid.return_to 'http://[host]/user/openid' != 'http://[host]/user/openid?[OpenIdResponse]
据我所知,问题是验证方法是将没有查询部分的URL与包含所有OpenID响应信息的整个URL进行比较。它从Zend_OpenId::selfUrl()
我正在使用doc页面中的验证码
$consumer = new Zend_OpenId_Consumer();
if($this->_request->getParam('openid_mode')) {
$id = $this->_request->getParam('openid_claimed_id');
if($this->_request->getParam('openid_mode') == 'id_res') {
if($consumer->verify($this->_request->getParams(),$id)) {
$status = 'VALID ' . $id;
}
else {
$status = 'INVALID ' . $id;
}
}
elseif($this->_request->getParam('openid_mode') == 'cancel') {
$status = 'CANCELLED';
}
}
我在这里做错了吗?
答案 0 :(得分:1)
也许这很有用
与Zend_Controller集成
最后说几句话 集成到模型 - 视图 - 控制器中 应用程序:例如Zend Framework 应用程序是使用 Zend_Controller类和它们一起使用 的对象 Zend_Controller_Response_Http类来 准备HTTP响应并发送它们 回到用户的网络浏览器。 Zend_OpenId_Consumer没有提供 任何GUI功能,但它执行 成功的HTTP重定向 Zend_OpenId_Consumer ::登录和 Zend_OpenId_Consumer ::检查。这些 重定向可能不正确或 如果有一些数据已经完全没有了 发送到网络浏览器。要正确 在MVC代码中执行HTTP重定向 真正的Zend_Controller_Response_Http 应该发送给 Zend_OpenId_Consumer ::登录或 Zend_OpenId_Consumer ::检查为 最后一个论点。
很奇怪,我刚用ZF 1.10.3在我的本地服务器上测试了OpenId_Consumer ... 没问题
我的行动
public function openidAction() {
$this->view->status = "";
if ($this->getRequest()->isPost()) {
$consumer = new Zend_OpenId_Consumer();
if (!$consumer->login($this->getRequest()->getParam('openid_identifier'))) {
$this->view->status = "OpenID login failed.";
}
} else if ($this->getRequest()->getParam('openid_mode')) {
if ($this->getRequest()->getParam('openid_mode') == "id_res") {
$consumer = new Zend_OpenId_Consumer();
if ($consumer->verify($this->getRequest()->getParams(), $id)) {
$this->view->status = "VALID " . htmlspecialchars($id);
} else {
$this->view->status = "INVALID " . htmlspecialchars($id);
}
} else if ($_GET['openid_mode'] == "cancel") {
$this->view->status = "CANCELLED";
}
}
}
我的观点
<p><?php echo "{$this->status}" ?></p>
<form method="post">
<fieldset>
<legend>OpenID Login</legend>
<input type="text" name="openid_identifier" value=""/>
<input type="submit" name="openid_action" value="login"/>
</fieldset>
</form>