Skip to content
Browse files

[project @ Add examples/discover.php tool]

  • Loading branch information...
1 parent aa82a2a commit 28b684f01c53232185c1d23fc7ae56a27798c68c tailor committed Jun 6, 2008
Showing with 103 additions and 0 deletions.
  1. +1 −0 CHANGES-2.1.0
  2. +5 −0 README
  3. +97 −0 examples/discover.php
View
1 CHANGES-2.1.0
@@ -15,6 +15,7 @@
* Server API: Auth_OpenID_OpenIDResponse::toHTML
* New Features
+ * Added examples/discover.php, an OpenID service discovery tool
* Add optional form_tag_attrs argument to
Auth_OpenID_ServerResponse::toFormMarkup for setting arbitrary
FORM element attributes
View
5 README
@@ -65,6 +65,11 @@ examples/README file for more details.
TROUBLESHOOTING
===============
+* If you're unable to use an OpenID URL with the library, you may want
+to try using the discover tool (examples/discover.php). This tool
+will perform OpenID discovery on the identifier and give a list of
+discovered OpenID services and their types.
+
* On some systems, PHP basedir restrictions prevent web servers from
opening a source of randomness, such as /dev/urandom. If your PHP
OpenID library has trouble getting a satisfactory source of
View
97 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>

0 comments on commit 28b684f

Please sign in to comment.
Something went wrong with that request. Please try again.