Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Yadis

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5

 Class Services_Yadis_Yadis

Description

This is the core of the PHP Yadis library. This is the only class a user needs to use to perform Yadis discovery. This class performs the discovery AND stores the result of the discovery.

First, require this library into your program source:

  require_once "Services/Yadis/Yadis.php";

To perform Yadis discovery, first call the "discover" method statically with a URI parameter:

  $http_response = array();
  $fetcher = Services_Yadis_Yadis::getHTTPFetcher();
  $yadis_object = Services_Yadis_Yadis::discover($uri,
                                    $http_response, $fetcher);

If the discovery succeeds, $yadis_object will be an instance of Services_Yadis_Yadis. If not, it will be null. The XRDS document found during discovery should have service descriptions, which can be accessed by calling

  $service_list = $yadis_object->services();

which returns an array of objects which describe each service. These objects are instances of Services_Yadis_Service. Each object describes exactly one whole Service element, complete with all of its Types and URIs (no expansion is performed). The common use case for using the service objects returned by services() is to write one or more filter functions and pass those to services():

  $service_list = $yadis_object->services(
                               array("filterByURI",
                                     "filterByExtension"));

The filter functions (whose names appear in the array passed to services()) take the following form:

  function myFilter(&$service) {
       // Query $service object here.  Return true if the service
       // matches your query; false if not.
  }

This is an example of a filter which uses a regular expression to match the content of URI tags (note that the Services_Yadis_Service class provides a getURIs() method which you should use instead of this contrived example):

  function URIMatcher(&$service) {
      foreach ($service->getElements('xrd:URI') as $uri) {
          if (preg_match("/some_pattern/",
                         $service->parser->content($uri))) {
              return true;
          }
      }
      return false;
  }

The filter functions you pass will be called for each service object to determine which ones match the criteria your filters specify. The default behavior is that if a given service object matches ANY of the filters specified in the services() call, it will be returned. You can specify that a given service object will be returned ONLY if it matches ALL specified filters by changing the match mode of services():

  $yadis_object->services(array("filter1", "filter2"),
                          SERVICES_YADIS_MATCH_ALL);

See SERVICES_YADIS_MATCH_ALL and SERVICES_YADIS_MATCH_ANY.

Services described in an XRDS should have a library which you'll probably be using. Those libraries are responsible for defining filters that can be used with the "services()" call. If you need to write your own filter, see the documentation for Services_Yadis_Service.

Located in /openid/Services/Yadis/Yadis.php (line 114)

Class Services_Yadis_Yadis
Method Summary
Constructor Services_Yadis_Yadis Services_Yadis_Yadis ()
Method void curlPresent ()
Method mixed discover (string $uri,  &$http_response,  &$fetcher, [array $extra_ns_map = null], [integer $timeout = 20], array $http_response, Services_Yadis_HTTPFetcher $fetcher)
Method void getHTTPFetcher ([ $timeout = 20])
Method array services ()
Methods
Constructor Services_Yadis_Yadis (line 285)

Instantiates an empty Services_Yadis_Yadis object. This constructor should not be used by any user of the library.

This constructor results in a completely useless object which must be populated with valid discovery information. Instead of using this constructor, call Services_Yadis_Yadis::discover($uri).

Services_Yadis_Yadis Services_Yadis_Yadis ()
curlPresent (line 132)
void curlPresent ()
discover (line 188)

This should be called statically and will build a Yadis instance if the discovery process succeeds. This implements Yadis discovery as specified in the Yadis specification.

  • return: Either null or an instance of Services_Yadis_Yadis, depending on whether the discovery succeeded.
mixed discover (string $uri,  &$http_response,  &$fetcher, [array $extra_ns_map = null], [integer $timeout = 20], array $http_response, Services_Yadis_HTTPFetcher $fetcher)
  • string $uri: The URI on which to perform Yadis discovery.
  • array $http_response: An array reference where the HTTP response object will be stored (see Services_Yadis_HTTPResponse.
  • Services_Yadis_HTTPFetcher $fetcher: An instance of a Services_Yadis_HTTPFetcher subclass.
  • array $extra_ns_map: An array which maps namespace names to namespace URIs to be used when parsing the Yadis XRDS document.
  • integer $timeout: An optional fetcher timeout, in seconds.
  • &$http_response
  • &$fetcher
getHTTPFetcher (line 122)

Returns an HTTP fetcher object. If the CURL extension is present, an instance of Services_Yadis_ParanoidHTTPFetcher is returned. If not, an instance of Services_Yadis_PlainHTTPFetcher is returned.

void getHTTPFetcher ([ $timeout = 20])
  • $timeout
services (line 303)

Returns the list of service objects as described by the XRDS document, if this yadis object represents a successful Yadis discovery.

array services ()

Documentation generated on Mon, 05 Mar 2007 21:33:23 +0000 by phpDocumentor 1.3.1