The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Net::Yadis

This package 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.

Net::Yadis::Service

An object representing a service tag in an XRDS document.

Methods

is_type

Takes a regexp or a string and returns a boolean value: do any of the <Type> tags in the <Service> tag match this type?

types

Returns a list of the contents of the <Type> tags of this service element.

uris

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

getAttribute

Get an attribute of the service tag by name.

 $priority = $service->getAttribute('priority');

findTag

Get the contents of a child tag of the service tag.

 $service->findTag($tag_name, $namespace);

For example:

 $delegate = $service->findTag('Delegate', $OPENID_NS);

xrds

Returns the xrds document as an XML::XPath for custom XPath queries.

node

Returns the XPath node of the <Service> tag, for custom XPath queries.