我在CakePHP上使用OpenID Simple Registration,如this post,但这对我不起作用。 我在控制器中的代码在这里:
function openid() {
$returnTo = 'http://'.$_SERVER['SERVER_NAME'].$this->webroot.'customers/openid';
if (!empty($this->data)) {
try {
$this->Openid->authenticate($this->data['OpenidUrl']['openid'], $returnTo, 'http://'.$_SERVER['SERVER_NAME'].$this->webroot, array('email'), array('nickname'));
} catch (InvalidArgumentException $e) {
$this->setMessage($this->data);
} catch (Exception $e) {
$this->setMessage($e->getMessage());
}
}
elseif (count($_GET) > 1) {
$response = $this->Openid->getResponse($returnTo);
$this->set("test",$_GET);
if ($response->status == Auth_OpenID_CANCEL) {
$this->Session->write('OpenIdStatus','Verification cancelled');
} elseif ($response->status == Auth_OpenID_FAILURE) {
$this->Session->write('OpenIdStatus','OpenID verification failed: '.$response->message);
} elseif ($response->status == Auth_OpenID_SUCCESS) {
$this->Session->write('OpenIdStatus','successfully authenticated!');
$sregResponse = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
$sregContents = $sregResponse->contents();
$this->set("message",$sregContents);
}
}
}
我错了什么?!
答案 0 :(得分:0)
authenticate
方法只需要当前版本中的四个参数。以下代码段:
$this->Openid->authenticate($this->data['OpenidUrl']['openid'], $returnTo, 'http://'.$_SERVER['SERVER_NAME'].$this->webroot, array('email'), array('nickname'));
必须看起来像:
$this->Openid->authenticate($this->data['OpenidUrl']['openid'], $returnTo, 'http://'.$_SERVER['SERVER_NAME'].$this->webroot, array('sreg_required' => array('email'), 'sreg_optional' => array('nickname')));