Zend framework 如何使用OpenID身份验证检索配置文件数据?(Zend框架)

Zend framework 如何使用OpenID身份验证检索配置文件数据?(Zend框架),zend-framework,authentication,openid,Zend Framework,Authentication,Openid,我阅读了一些教程,并提出了以下使用OpenID进行身份验证的脚本。但我不知道如何检索登录用户的个人资料数据,如全名或电子邮件。有人能帮我吗 $status=''; $auth=Zend_Auth::getInstance(); $post=array(); $get=$this->getRequest()->getParams(); if($this->getRequest()->isPost()){ $post=$this->getRequest()->getPost(); } $p

我阅读了一些教程,并提出了以下使用OpenID进行身份验证的脚本。但我不知道如何检索登录用户的个人资料数据,如全名或电子邮件。有人能帮我吗


$status='';
$auth=Zend_Auth::getInstance();
$post=array();
$get=$this->getRequest()->getParams();
if($this->getRequest()->isPost()){
    $post=$this->getRequest()->getPost();
}
$profile=new Zend_OpenId_Extension_Sreg(array(
    'nickname' => true,
    'email'    => true,
    'fullname' => true),null,1.1
);

if($auth->hasIdentity()){
    if(isset($get['openid_action']) && $get['openid_action']=='logout'){
        $auth->clearIdentity();
        $status="logged Out";
    }else{
        $status="logged in as ".$auth->getIdentity();   
    }
}else if(isset($post['openid_action']) && $post['openid_action']=='login' && $post['openid_identifier']){
    $result=$auth->authenticate(new Zend_Auth_Adapter_OpenId($post['openid_identifier']));
    $status='something went wrong';
}else if(isset($get['openid_mode'])){
    $result=$auth->authenticate(new Zend_Auth_Adapter_OpenId());
    if(!$result->isValid()){
        $auth->clearIdentity();
    }
    $status.= implode('
',$result->getMessages()); }else{ $status='You are not logged in'; } $this->view->status=$status;

好的,我知道怎么做了:


$status='';
$auth=Zend_Auth::getInstance();
$post=array();
$get=$this->getRequest()->getParams();
if($this->getRequest()->isPost()){
    $post=$this->getRequest()->getPost();
}

//changed nickname and fullname to false, so if provider didn't provide these, authentication won't fail.
$profile=new Zend_OpenId_Extension_Sreg(array(
    'nickname' => false,
    'email'    => true,
    'fullname' => false),null,1.1
);

if($auth->hasIdentity()){
    if(isset($get['openid_action']) && $get['openid_action']=='logout'){
        $auth->clearIdentity();
        $status="logged Out";
    }else{
        $status="logged in as ".$auth->getIdentity();   
    }
}else if(isset($post['openid_action']) && $post['openid_action']=='login' && $post['openid_identifier']){
    $result=$auth->authenticate(new Zend_Auth_Adapter_OpenId($post['openid_identifier'],null,null,null,$profile));
    $status='something went wrong';
}else if(isset($get['openid_mode'])){
    $result=$auth->authenticate(new Zend_Auth_Adapter_OpenId(null,null,null,null,$profile));
    if(!$result->isValid()){
        $auth->clearIdentity();
    }else{
        //here you have the information you need.
        $info=$profile->getProperties();
    }
    $status.= implode('
',$result->getMessages());

}else{
    $status='You are not logged in';
}
$this->view->status=$status;
但如果你想使用谷歌、雅虎或任何OpenID2.0提供商,你应该这样做