Skip to content

Commit

Permalink
examples how to generate XRD files for webfinger
Browse files Browse the repository at this point in the history
  • Loading branch information
cweiske committed Feb 9, 2012
1 parent 8ee76e1 commit 79cde30
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/gen-host-meta.php
@@ -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();
?>
24 changes: 24 additions & 0 deletions examples/gen-lrdd.php
@@ -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.