summaryrefslogtreecommitdiffstats
path: root/examples/consumer
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2007-03-30 18:34:20 +0000
committertailor <cygnus@janrain.com>2007-03-30 18:34:20 +0000
commit9c5e04d69400eabb9d2d12a6162d9b8e10c7ac2d (patch)
treef11a37cc94a1f405f33c061126a047f6443e99f1 /examples/consumer
parentd2793330df45cbba9948266d27ef51a928e47837 (diff)
downloadphp-openid-9c5e04d69400eabb9d2d12a6162d9b8e10c7ac2d.zip
php-openid-9c5e04d69400eabb9d2d12a6162d9b8e10c7ac2d.tar.gz
php-openid-9c5e04d69400eabb9d2d12a6162d9b8e10c7ac2d.tar.bz2
[project @ Update example consumer to use SReg API]
Diffstat (limited to 'examples/consumer')
-rw-r--r--examples/consumer/common.php5
-rw-r--r--examples/consumer/finish_auth.php12
-rw-r--r--examples/consumer/try_auth.php11
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