diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/consumer/common.php | 5 | ||||
-rw-r--r-- | examples/consumer/finish_auth.php | 12 | ||||
-rw-r--r-- | examples/consumer/try_auth.php | 11 |
3 files changed, 23 insertions, 5 deletions
diff --git a/examples/consumer/common.php b/examples/consumer/common.php index c4eed70..c184467 100644 --- a/examples/consumer/common.php +++ b/examples/consumer/common.php @@ -22,6 +22,11 @@ function doIncludes() { * OpenID information. */ require_once "Auth/OpenID/FileStore.php"; + + /** + * Require the Simple Registration extension API. + */ + require_once "Auth/OpenID/SReg.php"; } doIncludes(); diff --git a/examples/consumer/finish_auth.php b/examples/consumer/finish_auth.php index 64655a3..c4285d5 100644 --- a/examples/consumer/finish_auth.php +++ b/examples/consumer/finish_auth.php @@ -32,14 +32,20 @@ function run() { $success .= ' (XRI CanonicalID: '.$response->endpoint->canonicalID.') '; } - $sreg = $response->extensionResponse('sreg', true); + $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response); + + $sreg = $sreg_resp->contents(); if (@$sreg['email']) { $success .= " You also returned '".$sreg['email']."' as your email."; } - if (@$sreg['postcode']) { - $success .= " Your postal code is '".$sreg['postcode']."'"; + if (@$sreg['nickname']) { + $success .= " Your nickname is '".$sreg['nickname']."'."; + } + + if (@$sreg['fullname']) { + $success .= " Your fullname is '".$sreg['fullname']."'."; } } diff --git a/examples/consumer/try_auth.php b/examples/consumer/try_auth.php index 691683e..09d680f 100644 --- a/examples/consumer/try_auth.php +++ b/examples/consumer/try_auth.php @@ -49,8 +49,15 @@ function run() { displayError("Authentication error; not a valid OpenID."); } - // Add an extension arg for optional Simple Registration parameters. - $auth_request->addExtensionArg('sreg', 'optional', 'email,postcode'); + $sreg_request = Auth_OpenID_SRegRequest::build( + // Required + array('nickname'), + // Optional + array('fullname', 'email')); + + if ($sreg_request) { + $auth_request->addExtension($sreg_request); + } // Redirect the user to the OpenID server for authentication. // Store the token for this authentication so we can verify the |