Request an email address from an OpenID provider in PHP

What is the easiest way to request an email address from an OpenID provider?

Is there a good PHP library that simplifies this problem?

I know that providers implement things differently. I heard you need to do both a simple registration and an exchange of attributes. I would especially like to make sure that he worked with major providers such as MyOpenID and Google.

Related but inadequate questions:

+3
source share
2 answers

JanRain Open ID PHP Library, ( ) , OpenID. MyOpenID, JanRain.

, Zend ( JanRain ), , Zend Framework.

, OpenID Simple Registration Extension.

Zend Reference , . , :

//require e-mail, get nickname and fullname if available
$sreg = new Zend_OpenId_Extension_Sreg(array(
    'nickname'=>false,
    'email'=>true,
    'fullname'=>false), null, 1.1);
$consumer = new Zend_OpenId_Consumer();
if (!$consumer->login($openid, $returnUrl, null, $sreg)) {
    die("OpenID login failed.");
}

JanRain , - , try_auth.php ( , , ):

$auth_request = $consumer->begin($openid);
$sreg_request = Auth_OpenID_SRegRequest::build(
                                 // Required
                                 array('email'),
                                 // Optional
                                 array('fullname', 'nickname'));
$auth_request->addExtension($sreg_request);

Exchange JanRain Auth_OpenID_AX, Zend AX.

+2

Source: https://habr.com/ru/post/1722710/


All Articles