我需要通过 OpenId 注册用户(例如 google)
但它不起作用!
我已经看到了一些主题: http:
//framework.zend.com/issues/browse/ZF-6905
Zend OpenId and Google
And others..
但这一切都行不通!
我需要获取用户信息(例如登录名或电子邮件),但如果我这样使用
// $data['openidIdentifier'] = 'https://www.google.com/accounts/o8/id';
public function loginByOpenIdAction() {
$request = $this->getRequest();
$form = new Application_Form_UsersLoginByOpenId();
$this->view->headTitle('Login by OpenId');
if ($request->isPost()) {
$data = $request->getPost();
if ($form->isValid($data)) {
$consumer = new Zend_OpenId_Consumer();
$backUrl = $this->getHelper('Url')->url(array('controller' => 'users', 'action' => 'signup-from-open-id'));
if (!$consumer->login($data['openidIdentifier'], $backUrl)) {
$this->view->error = 'Can`t connect to OpenId provider';
}
}
}
$this->view->form = $form;
}
public function signupFromOpenIdAction() {
$consumer = new Zend_OpenId_Consumer();
$data = &$_GET;
$sreg = new Zend_OpenId_Extension_Sreg(array(
'nickname' => true,
'email' => false,
'fullname' => false), null, 1.1
);
if ($consumer->verify($data, $id, $sreg)) {
$properties = $sreg->getProperties();
var_dump($properties);
var_dump('allow', $id);
} else {
var_dump('deny', $id, $consumer);
}
die;
}
输出是:
字符串“拒绝”(长度=4) 字符串“https://www.google.com/accounts/o8/id?id=fooBarFooBar”(长度=80) 对象(Zend_OpenId_Consumer)[61] 受保护的“_storage”=> 对象(Zend_OpenId_Consumer_Storage_File)[62] 私人'_dir' => 字符串'/tmp/azat/openid/consumer'(长度=25) protected '_dumbMode' => boolean false 受保护的“_cache”=> 大批 空的 私人'_httpClient' => null 私人'_session' => null private '_error' => string 'Extension::parseResponse failure' (length=32)
请帮助:我如何从 openid 服务器(例如谷歌)获取注册用户的用户信息?
如果我使用$consumer->verify($data, $id)
比一切都好,但我需要用户信息才能注册
而且我从这个问题http://framework.zend.com/issues/browse/ZF-6905使用 Zend_OpenId_Consumer ,因为对于本机 Zend_OpenId_Consumer$consumer->verify($data, $id)
这不起作用
也没有提供使用一些经纪人的建议,或者其他与 openid 一起工作的库。