Permalink
Browse files

examples how to generate XRD files for webfinger

  • Loading branch information...
1 parent 8ee76e1 commit 79cde30a67f79de7fa48c0ad5d311277eee48286 @cweiske cweiske committed Feb 9, 2012
Showing with 44 additions and 0 deletions.
  1. +20 −0 examples/gen-host-meta.php
  2. +24 −0 examples/gen-lrdd.php
View
@@ -0,0 +1,20 @@
+<?php
+/**
+ * Generates a .well-known/host-meta file that's described
+ * in "RFC 6415: Web Host Metadata".
+ *
+ * @author Christian Weiske <cweiske@php.net>
+ * @link http://tools.ietf.org/html/rfc6415
+ */
+require_once 'XML/XRD.php';
+$x = new XML_XRD();
+
+$x->subject = 'example.org';
+$x->aliases[] = 'example.com';
+$x->links[] = new XML_XRD_Element_Link(
+ 'lrdd', 'http://example.org/gen-lrdd.php?a={uri}',
+ 'application/xrd+xml', true
+);
+
+echo $x->toXML();
+?>
View
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Generate a LRDD file that contains information about a user.
+ *
+ * @author Christian Weiske <cweiske@php.net>
+ * @link http://tools.ietf.org/html/draft-hammer-discovery-06
+ */
+require_once 'XML/XRD.php';
+$x = new XML_XRD();
+$x->subject = 'user@example.org';
+
+//add link to the user's OpenID
+$x->links[] = new XML_XRD_Element_Link(
+ 'http://specs.openid.net/auth/2.0/provider',
+ 'http://id.example.org/user'
+);
+//add link to user's home page
+$x->links[] = new XML_XRD_Element_Link(
+ 'http://xmlns.com/foaf/0.1/homepage',
+ 'http://example.org/~user/'
+);
+
+echo $x->toXML();
+?>

0 comments on commit 79cde30

Please sign in to comment.