This package performs the Yadis service discovery protocol, and parses XRDS xml documents.
This constructor performs the discovery protocol on a url and returns a yadis object that parses the XRDS document for you.
eval { $yadis=Net::Yadis->discover($url); } warn "Yadis failed: $@" if $@;
Will die on errors: HTTP errors, missing Yadis magic, malformed XRDS
You may also skip discovery and go straight to xrds parsing with the new constructor.
new
$yadis = Net::Yadis->new($yadis_url, $xrds_url, $xml);
the identity URL
where we got the xrds document
the XRDS xml as text
We don't trap death from XML::XPath; malformed xml causes this
The XML text of the XRDS document.
The Yadis URL.
The URL where the XRDS document was found.
The XML::XPath object used internally is made available to allow custom XPath queries.
An array of Net::Yadis::Service objects representing the services advertised in the XRDS file.
Pass in a filter function reference to this guy. The filter function must take a Net::Yadis::Service object, and return a scalar of some sort or undef. The scalars returned from the filter will be returned in an array from this method.
my $filter = sub { my $service = shift; if ($service->is_type($typere)) { # here we simply return the service object, but you may return # something else if you wish to extract the data and discard # the xpath object contained in the service object. return $service; } else { return undef; } }; my $typeservices = $yadis->filter_services($filter);
A predefined filtering method that takes a regexp for filtering service types.
Hey, a perl generator! sequential calls will return the services one at a time, in ascending priority order with ties randomly decided. make sure that the type argument is identical for each call, or the list will start again from the top. You'll have to store the yadis object in a session for this guy to be useful.
An object representing a service tag in an XRDS document.
Takes a regexp or a string and returns a boolean value: do any of the <Type> tags in the <Service> tag match this type?
<Type>
<Service>
Returns a list of the contents of the <Type> tags of this service element.
Returns a list of the contents of the <URI> tags of this service element, in priority order, ties randomly decided.
<URI>
another perl 'generator'. sequential calls will return the uris one at a time, in ascending priority order with ties randomly decided
Get an attribute of the service tag by name.
$priority = $service->getAttribute('priority');
Get the contents of a child tag of the service tag.
$service->findTag($tag_name, $namespace);
For example:
$delegate = $service->findTag('Delegate', $OPENID_NS);
Returns the xrds document as an XML::XPath for custom XPath queries.
Returns the XPath node of the <Service> tag, for custom XPath queries.
To install Net::Yadis, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Yadis
CPAN shell
perl -MCPAN -e shell install Net::Yadis
For more information on module installation, please visit the detailed CPAN module installation guide.