Generating XRD files
Generating XRD files is made by creating an XML_XRD object, setting
the properties and calling the generation method
to()
with either xml
or json
as only
parameter.
<?php
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->to('xml');
?>
Generate a LRDD file
<?php
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->to('xml');
?>