Zend OpenId 2.0 支持
我需要通过 OpenId 注册用户(例如 google)
但它不起作用!
我已经看到一些主题:
http://framework.zend.com/issues/browse/ZF-6905
Zend OpenId 和 Google
还有其他人..
但这一切都行不通!
我需要获取用户信息(例如登录名或电子邮件),但如果我像这样使用
// $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;
}
输出是:
string 'deny' (length=4) string 'https://www.google.com/accounts/o8/id?id=fooBarFooBar' (length=80) object(Zend_OpenId_Consumer)[61] protected '_storage' => object(Zend_OpenId_Consumer_Storage_File)[62] private '_dir' => string '/tmp/azat/openid/consumer' (length=25) protected '_dumbMode' => boolean false protected '_cache' => array empty private '_httpClient' => null private '_session' => null private '_error' => string 'Extension::parseResponse failure' (length=32)
请帮助:如何从 openid 服务器(例如谷歌)获取注册用户的用户信息?
如果我使用 $consumer->verify($data, $id)
则一切正常,但我需要用户信息进行注册
而且我还使用此问题中的 Zend_OpenId_Consumer http://framework.zend.com/issues/browse/ZF-6905,因为使用本机 Zend_OpenId_Consumer $consumer->verify($data, $id)
这不起作用
另外建议使用一些代理,或其他与 openid 一起使用的库不提供。
I need to signup a user by OpenId (for example google)
But it is not working!
I have already see some topics:
http://framework.zend.com/issues/browse/ZF-6905
Zend OpenId and Google
And others..
But all of that is not works!
I need to fetch user info (such as login or email) but if I use like this
// $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;
}
And the output is:
string 'deny' (length=4) string 'https://www.google.com/accounts/o8/id?id=fooBarFooBar' (length=80) object(Zend_OpenId_Consumer)[61] protected '_storage' => object(Zend_OpenId_Consumer_Storage_File)[62] private '_dir' => string '/tmp/azat/openid/consumer' (length=25) protected '_dumbMode' => boolean false protected '_cache' => array empty private '_httpClient' => null private '_session' => null private '_error' => string 'Extension::parseResponse failure' (length=32)
Please help: how can i fetch user info from openid server (for example google) for signup user?
If I use $consumer->verify($data, $id)
than all ok, but I need user info for signup
And also I use Zend_OpenId_Consumer from this issue http://framework.zend.com/issues/browse/ZF-6905, because with native Zend_OpenId_Consumer $consumer->verify($data, $id)
this is not works
Also suggestions to use some brokers, or other libs working with openid not offer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Akeem Philbert 有一篇文章和一些文件,您可以使用它们来扩展 ZF 中的 OpenID 实现,以至少支持将 OpenID 与 Google 结合使用。
http://ak33m.com/?p=71
还有一篇关于让 ZF 上使用 Facebook 和 Twitter
在http://shortrecipes .blogspot.com/2011/02/example-of-openid-facebook-and-twitter.html
正如 @takeshin 所指出的,遗憾的是,ZF 尚未完全支持 OpenID 2.0。
Akeem Philbert has a post and some files you can use to extend the OpenID implementation in ZF to support at least using OpenID with Google.
http://ak33m.com/?p=71
There is also a blog post about getting ZF to work with Facebook and Twitter at
http://shortrecipes.blogspot.com/2011/02/example-of-openid-facebook-and-twitter.html
As @takeshin has pointed out, sadly, ZF doesn't not yet fully support OpenID 2.0.
AFAIK Zend Framework 尚未完全支持 OpenID 2.0。
请参阅此 ZF 问题:
您可以使用其他外部库:
AFAIK Zend Framework does not support OpenID 2.0 fully yet.
Please refer to this ZF issue:
http://www.framework.zend.com/issues/browse/ZF-6905?page=com.atlassian.streams.streams-jira-plugin%3Aactivity-stream-issue-tab
You may use other, external libraries instead: