Services_Yadis
[ class tree: Services_Yadis ] [ index: Services_Yadis ] [ all elements ]

Class: Services_Yadis

Source Location: /Services_Yadis-0.5.2/Services/Yadis.php

Class Overview


Services_Yadis class


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 98]
Services_Yadis class

Services_Yadis will provide a method of Service Discovery implemented in accordance with the Yadis Specification 1.0. This describes a protocol for locating an XRD document which details Services available. The XRD is typically specific to a single user, identified by their Yadis ID. Services_Yadis_XRDS will be a wrapper which is responsible for parsing and presenting an iterable list of Services_Yadis_Service objects holding the data for each specific Service discovered.

Note that class comments cannot substitute for a full understanding of the rules and nuances required to implement the Yadis protocol. Where doubt exists, refer to the Yadis Specification 1.0 at: http://yadis.org/papers/yadis-v1.0.pdf Departures from the specification should be regarded as bugs ;).

Example usage:

Example 1: OpenID Service Discovery

$openid = 'http://padraic.astrumfutura.com'; $yadis = new Services_Yadis($openid); $yadis->addNamespace('openid', 'http://openid.net/xmlns/1.0'); $serviceList = $yadis->discover();

foreach ($serviceList as $service) { $types = $service->getTypes(); echo $types[0], ' at ', implode(', ', $service->getUris()), PHP_EOL; echo 'Priority is ', $service->->getPriority(), PHP_EOL; }

Possible Result @index[0] (indicates we may send Auth 2.0 requests for OpenID):

http://specs.openid.net/auth/2.0/server at http://www.myopenid.com/server Priority is 0



[ Top ]


Class Variables

$httpRequest =  null

[line 193]

HTTP_Request2 object utilised by this class if externally set
  • Access: protected

Type:   HTTP_Request2


[ Top ]

$httpRequestOptions = array()

[line 186]

  • Access: protected

Type:   mixed


[ Top ]

$httpResponse =  null

[line 132]

Holds the response received during Service Discovery.
  • Access: protected

Type:   HTTP_Request2_Response


[ Top ]

$metaHttpEquivUrl =  ''

[line 141]

A URL parsed from a HTML document's <meta> element inserted in accordance with the Yadis Specification and which points to a Yadis XRD document.
  • Access: protected

Type:   string


[ Top ]

$namespace =  null

[line 158]

Instance of Services_Yadis_Xrds_Namespace for managing namespaces associated with an XRDS document.
  • Access: protected



[ Top ]

$validHtmlContentTypes = array(
        'text/html',
        'application/xhtml+xml',
        'application/xml',
        'text/xml'
    )

[line 169]

Array of valid HTML Content-Types. Required since Yadis states agents must parse a document if received as the first response and with an MIME type indicating HTML or XHTML. Listed in order of priority, with HTML taking priority over XHTML.

Type:   array


[ Top ]

$xrdsLocationHeaderUrl =  ''

[line 150]

A URI parsed from an X-XRDS-Location response-header. This value must point to a Yadis XRD document otherwise the Yadis discovery process should be considered to have failed.
  • Access: protected

Type:   string


[ Top ]

$xriIdentifiers = array(
        '=', '$', '!', '@', '+'
    )

[line 182]

  • Access: protected

Type:   mixed


[ Top ]

$yadisId =  ''

[line 116]

The current Yadis ID; this is the raw form initially submitted prior to any transformation/validation as an URL. This *may* allow IRI support in the future given IRIs map to URIs and adoption of the IRI standard and are entering common use internationally.
  • Access: protected

Type:   string


[ Top ]

$yadisUrl =  ''

[line 125]

The current Yadis URL; this is a URL either validated or transformed from the initial Yadis ID. This URL is used to make the initial HTTP GET request during Service Discovery.
  • Access: protected

Type:   string


[ Top ]



Method Detail

__construct (Constructor)   [line 209]

void __construct( [string $yadisId = null], [ $namespaces = array()])

Class Constructor

Allows settings of the initial Yadis ID (an OpenID URL for example) and an optional list of additional namespaces. For example, OpenID uses a namespace such as: xmlns:openid="http://openid.net/xmlns/1.0" Namespaces are assigned to a Services_Yadis_Xrds_Namespace container object to be passed more easily to other objects being

  • Access: public

Parameters:

string   $yadisId     Optional Yadis ID
array   $namespaces     Optional array of namespaces

[ Top ]

addNamespace   [line 359]

Services_Yadis addNamespace( string $namespace, string $namespaceUrl)

Add a single namespace to be utilised by the XML parser when it receives a valid XRD document.
  • Access: public

Parameters:

string   $namespace     The namespace name
string   $namespaceUrl     The namespace url

[ Top ]

addNamespaces   [line 344]

Services_Yadis addNamespaces( $namespaces)

Add a list (array) of additional namespaces to be utilised by the XML parser when it receives a valid XRD document.
  • Access: public

Parameters:

array   $namespaces     Array of namespaces

[ Top ]

discover   [line 396]

Services_Yadis_Xrds|boolean discover( )

Performs Service Discovery, i.e. the requesting and parsing of a valid Yadis (XRD) document into a list of Services and Service Data. The return value will be an instance of Services_Yadis_Xrds which will implement SeekableIterator. Returns FALSE on failure.
  • Throws: Services_Yadis_Exception
  • Access: public

[ Top ]

get   [line 534]

HTTP_Request2 get( string $url)

Use the HTTP_Request2 to issue an HTTP GET request carrying the "Accept" header value of "application/xrds+xml". This can allow servers to quickly respond with a valid XRD document rather than forcing the client to follow the X-XRDS-Location bread crumb trail.
  • Access: protected

Parameters:

string   $url     URL

[ Top ]

getHttpRequest   [line 494]

HTTP_Request2 getHttpRequest( )

Gets the HTTP_Request2 object
  • Access: public

[ Top ]

getHttpRequestOptions   [line 236]

array getHttpRequestOptions( )

Get options to be passed to the PEAR HTTP_Request2 constructor
  • Access: public

[ Top ]

getHTTPResponse   [line 469]

HTTP_Request2_Response getHTTPResponse( )

Return the final HTTP response
  • Access: public

[ Top ]

getNamespace   [line 372]

string|null getNamespace( string $namespace)

Return the value of a specific namespace.
  • Access: public

Parameters:

string   $namespace     Namespace name

[ Top ]

getNamespaces   [line 382]

array getNamespaces( )

Returns an array of all currently set namespaces.
  • Access: public

[ Top ]

getResponseType   [line 512]

integer getResponseType( $response, HTTP_Request2_Response $request)

Run any instance of HTTP_Request2_Response through a set of filters to determine the Yadis Response type which in turns determines how the response should be reacted to or dealt with.
  • Access: protected

Parameters:

HTTP_Request2_Response   $request     Instance of HTTP_Request2_Response
HTTP_Request2_Response   $response     

[ Top ]

getYadisId   [line 265]

string getYadisId( )

Returns the original Yadis ID string set for this class.
  • Access: public

[ Top ]

getYadisUrl   [line 326]

string getYadisUrl( )

Returns the Yadis URL. This will usually be identical to the Yadis ID, unless the Yadis ID (in the future) was one of IRI, XRI or i-name which required transformation to a valid URI.
  • Access: public

[ Top ]

isMetaHttpEquiv   [line 608]

boolean isMetaHttpEquiv( $response)

Assuming this user is hosting a third party sourced identity under an alias personal URL, we'll need to check if the website's HTML body has a http-equiv meta element with a content attribute pointing to where we can fetch the XRD document.
  • Throws: Services_Yadis_Exception
  • Access: protected

Parameters:

HTTP_Request2_Response   $response     Instance of HTTP_Request2_Response

[ Top ]

isXrdsContentType   [line 586]

boolean isXrdsContentType( $response)

Checks whether the Response contains the XRDS resource. It should, per the specifications always be served as application/xrds+xml
  • Access: protected

Parameters:

HTTP_Request2_Response   $response     Instance of HTTP_Request2_Response

[ Top ]

isXrdsLocationHeader   [line 559]

boolean isXrdsLocationHeader( $response)

Checks whether the Response contains headers which detail where we can find the XRDS resource for this user. If exists, the value is set to the private $xrdsLocationHeaderUrl property.
  • Access: protected

Parameters:

HTTP_Request2_Response   $response     Instance of HTTP_Request2_Response

[ Top ]

parseXrds   [line 666]

Services_Yadis_Xrds|boolean parseXrds( string $xrdsDocument)

Creates a new Services_Yadis_Xrds object which uses SimpleXML to parse the XML into a list of Iterable Services_Yadis_Service objects.
  • Access: protected

Parameters:

string   $xrdsDocument     The plaintext XRDS document

[ Top ]

setHttpRequest   [line 484]

void setHttpRequest( $request)

Setter for custom HTTP_Request2 type object
  • Access: public

Parameters:

HTTP_Request2   $request     Instance of HTTP_Request2

[ Top ]

setHttpRequestOptions   [line 225]

Services_Yadis setHttpRequestOptions( $options)

Set options to be passed to the PEAR HTTP_Request2 constructor
  • Access: public

Parameters:

array   $options     Array of options for HTTP_Request

[ Top ]

setYadisId   [line 254]

void setYadisId( string $yadisId)

A Yadis ID is usually an URL, but can also include an IRI, or XRI i-name.

The initial version will support URLs as standard before examining options for supporting alternatives (IRI,XRI,i-name) since they require additional validation and conversion steps (e.g. Punycode for IRI) before use.

Note: The current Validate classes currently do not have complete IDNA validation support for Internationalised Domain Names. To be addressed.

  • Access: public

Parameters:

string   $yadisId     The Yadis ID

[ Top ]

setYadisUrl   [line 285]

Services_Yadis setYadisUrl( string $yadisId)

Attempts to create a valid URI based on the value of the parameter which would typically be the Yadis ID.

Note: This currently only supports XRI transformations.

  • Throws: Services_Yadis_Exception
  • Access: public

Parameters:

string   $yadisId     The Yadis ID

[ Top ]

validateURI   [line 679]

bool validateURI( string $uri)

Wrapper for Validate::uri() to avoid non-static strict warnings
  • Access: public

Parameters:

string   $uri     The URI to validate

[ Top ]


Documentation generated on Mon, 19 May 2014 08:30:03 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.