JanRain has a Open ID PHP Library, one of the first libraries (I believe) from a company centric to OpenID. You mentioned working with MyOpenID, which JanRain s site.
That said, personally I use the Zend Library now (I played with the JanRain library years ago), just because I generally develop using the Zend Framework.
Here are some code examples if the provider uses the OpenID Simple Registration Extension.
This section of the Zend Reference guide shows how to request user information with the authentication request. Here s their example code edited for your needs:
//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.");
}
Accomplishing the same with the JanRain library is similar, here s some code taken from from the try_auth.php file of the library package (I edited it to show the basic functions you re looking for):
$auth_request = $consumer->begin($openid);
$sreg_request = Auth_OpenID_SRegRequest::build(
// Required
array( email ),
// Optional
array( fullname , nickname ));
$auth_request->addExtension($sreg_request);
For Attribute Exchange check out the JanRain Auth_OpenID_AX Classes, in the Zend Library there s a feature request for AX support.