This module contains the HTTP fetcher interface
PHP versions 4 and 5
LICENSE: See the COPYING file included in this distribution.
This class is the interface for HTTP fetchers the Yadis library uses. This interface is only important if you need to write a new fetcher for some reason.
private
Yadis service manager to be used during yadis-driven authentication attempts.
The base session class used by the Services_Yadis_Manager. This class wraps the default PHP session machinery and should be subclassed if your application doesn't use PHP sessioning.
The Yadis service manager which stores state in a session and iterates over <Service> elements in a Yadis XRDS document and lets a caller attempt to use each one. This is used by the Yadis library internally.
State management for discovery.
High-level usage pattern is to call .getNextService(discover) in order to find the next available service for this user for this session. Once a request completes, call .finish() to clean up the session state.
This module contains the CURL-based HTTP fetcher implementation.
PHP versions 4 and 5
LICENSE: See the COPYING file included in this distribution.
A paranoid Services_Yadis_HTTPFetcher class which uses CURL for fetching.
This is the HTML pseudo-parser for the Yadis library.
PHP versions 4 and 5
LICENSE: See the COPYING file included in this distribution.
This class is responsible for scanning an HTML string to find META tags and their attributes. This is used by the Yadis discovery process. This class must be instantiated to be used.
This module contains the plain non-curl HTTP fetcher implementation.
PHP versions 4 and 5
LICENSE: See the COPYING file included in this distribution.
Interface import; need to inherit from the base HTTP fetcher class. This class implements a plain, hand-built socket-based fetcher which will be used in the event that CURL is unavailable.
XML-parsing classes to wrap the domxml and DOM extensions for PHP 4 and 5, respectively.
The base class for wrappers for available PHP XML-parsing extensions. To work with this Yadis library, subclasses of this class MUST implement the API as defined in the remarks for this class. Subclasses of Services_Yadis_XMLParser are used to wrap particular PHP XML extensions such as 'domxml'. These are used internally by the library depending on the availability of supported PHP XML extensions.
This concrete implementation of Services_Yadis_XMLParser implements the appropriate API for the 'domxml' extension which is typically packaged with PHP 4. This class will be used whenever the 'domxml' extension is detected. See the Services_Yadis_XMLParser class for details on this class's methods.
This concrete implementation of Services_Yadis_XMLParser implements the appropriate API for the 'dom' extension which is typically packaged with PHP 5. This class will be used whenever the 'dom' extension is detected. See the Services_Yadis_XMLParser class for details on this class's methods.
This module contains the XRDS parsing code.
PHP versions 4 and 5
LICENSE: See the COPYING file included in this distribution.
This class represents a <Service> element in an XRDS document. Objects of this type are returned by Services_Yadis_XRDS::services() and Services_Yadis_Yadis::services(). Each object corresponds directly to a <Service> element in the XRDS and supplies a getElements($name) method which you should use to inspect the element's contents. See Services_Yadis_Yadis for more information on the role this class plays in Yadis discovery.
This class performs parsing of XRDS documents.
You should not instantiate this class directly; rather, call parseXRDS statically:
$xrds = Services_Yadis_XRDS::parseXRDS($xml_string);
If the XRDS can be parsed and is valid, an instance of Services_Yadis_XRDS will be returned. Otherwise, null will be returned. This class is used by the Services_Yadis_Yadis::discover method.
The core PHP Yadis implementation.
PHP versions 4 and 5
LICENSE: See the COPYING file included in this distribution.
Need both fetcher types so we can use the right one based on the presence or absence of CURL. Need this for parsing HTML (looking for META tags). Need this to parse the XRDS document during Yadis discovery. 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.