下面是我的OpenId实现的一个工作示例。我使用hyves.nl作为OpenId提供商,但这也适用于me.yahoo.com,可能也适用于其他OpenId提供商(但不是谷歌)。
到目前一切尚好。但现在我想从我的hyves配置文件中获取昵称和/或全名。但是,当我在$props数组中将昵称和/或全名设置为真时,我就不能再登录了。
我在这里做错了什么?
class TestController extends Zend_Controller_Action
{
private $_sreg = null;
public function init()
{
$props = array('nickname' => false,
'email' => false,
'fullname' => false,
'dob' => false,
'gender' => false,
'postcode' => false,
'country' => false,
'language' => false,
'timezone' => false);
$this->_sreg = new Zend_OpenId_Extension_Sreg($props);
}
public function loginAction()
{
$consumer = new Zend_OpenId_Consumer();
if (!$consumer->login('hyves.nl', 'http://localhost/trouwcom/public/test/verify', 'http://localhost/trouwcom', $this->_sreg))
{
echo 'Login failed';
}
$this->_helper->viewRenderer->setNoRender();
}
public function verifyAction()
{
$consumer = new Zend_OpenId_Consumer();
if ($consumer->verify($_GET, $id, $this->_sreg))
{
echo 'VALID ' . htmlspecialchars($id);
$data = $this->_sreg->getProperties();
print_r($data);
}
else
{
echo 'INVALID ' . htmlspecialchars($id);
}
$this->_helper->viewRenderer->setNoRender();
}
}发布于 2009-08-13 11:36:53
会不会是这个bug?http://framework.zend.com/issues/browse/ZF-5266
发布于 2010-02-02 20:54:58
不知道你是否已经找到答案了。但是如果你没有,或者其他人像我一样读了这个问题,并且有同样的问题,我就找到了答案。
openId提供程序"hyves.nl“的问题在于,它们不是通过$_GET而是通过$_POST返回验证参数。
# This works
$consumer->verify($_POST, $id, $this->_sreg);https://stackoverflow.com/questions/1271437
复制相似问题