diff options
author | tailor <cygnus@janrain.com> | 2008-06-06 22:43:56 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2008-06-06 22:43:56 +0000 |
commit | 28b684f01c53232185c1d23fc7ae56a27798c68c (patch) | |
tree | 90dd86cae59435b915b4a5618c4fa1e1ec568d9d /examples | |
parent | aa82a2ace4ca8675f3ac0b61b5fb27d3b35d01a9 (diff) | |
download | php-openid-28b684f01c53232185c1d23fc7ae56a27798c68c.zip php-openid-28b684f01c53232185c1d23fc7ae56a27798c68c.tar.gz php-openid-28b684f01c53232185c1d23fc7ae56a27798c68c.tar.bz2 |
[project @ Add examples/discover.php tool]
Diffstat (limited to 'examples')
-rw-r--r-- | examples/discover.php | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/examples/discover.php b/examples/discover.php new file mode 100644 index 0000000..4ea7c30 --- /dev/null +++ b/examples/discover.php @@ -0,0 +1,97 @@ +<?php +require_once "Auth/OpenID/Discover.php"; +require_once "Auth/Yadis/Yadis.php"; + +function getOpenIDIdentifier() +{ + return $_GET['openid_identifier']; +} + +function escape($x) +{ + return htmlentities($x); +} + + +$identifier = getOpenIDIdentifier(); +?> +<html> +<head> +<title>OpenID discovery</title> +</head> +<body> + <h2>OpenID discovery tool</h2> + <p> + Enter an OpenID URL to begin discovery: + </p> + <form> + <input type="text" name="openid_identifier" size="40" /> + <input type="submit" value="Begin" /> + </form> +<? +if ($identifier) { + + $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); + list($normalized_identifier, $endpoints) = Auth_OpenID_discover( + $identifier, $fetcher); + +?> + <h3>Discovery Results for <?= escape($identifier) ?></h3> + + <table cellpadding="7" cellspacing="0"> + <tbody> + <tr> + <th>Claimed Identifier</th> + <td><?= escape($normalized_identifier) ?></td> + </tr> +<? +if (!$endpoints) { +?> + <tr> + <td colspan="2">No OpenID services discovered.</td> + </tr> +<? +} else { +?> + <tr> + <td colspan="2">Discovered OpenID services:</td> + </tr> +<? +foreach ($endpoints as $endpoint) { +?> + <tr> + <td colspan="2"><hr/></td> + </tr> + <tr> + <th>Server URL</th> + <td><tt><?= escape($endpoint->server_url) ?></tt></td> + </tr> + <tr> + <th>Local ID</th> + <td><tt><?= escape($endpoint->local_id) ?></tt></td> + </tr> + <tr> + <td colspan="2"> + <h3>Service types:</h3> + <ul> +<? +foreach ($endpoint->type_uris as $type_uri) { +?> + <li><tt><?= escape($type_uri) ?></tt></li> +<? +} +?> + </ul> + </td> + </tr> +<? +} +} +?> + </tbody> +</table> +<? +} +?> +</body> +</html>
\ No newline at end of file |