Net::Yadis is a Perl module that performs the Yadis service discovery protocol, and parses XRDS xml documents.
Methods
discover
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
new
You may also skip discovery and go straight to xrds parsing with the new constructor.
$yadis = Net::Yadis->new($yadis_url, $xrds_url, $xml);
$yadis_url
the identity URL
$xrds_url
where we got the xrds document
$xml
the XRDS xml as text
We don't trap death from XML::XPath; malformed xml causes this
Accessor methods
xml
The XML text of the XRDS document.
url
The Yadis URL.
xrds_url
The URL where the XRDS document was found.
xrds_xpath
The XML::XPath object used internally is made available to allow custom XPath queries.
services
An array of Net::Yadis::Service objects representing the services advertised in the XRDS file.
filter_services
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.
Example
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);
services_of_type
A predefined filtering method that takes a regexp for filtering service types.
service_of_type
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.
Product's homepage
Requirements:
· Perl