Comments: on this page. Click to read or post your own.

Class RestfulService

Description

RestfulService class allows you to consume various RESTful APIs.

Through this you could connect and aggregate data of various web services. For more info visit wiki documentation - http://doc.silverstripe.com/doku.php?id=restfulservice

Located in /sapphire/api/RestfulService.php (line 9)

Object
   |
   --ViewableData
      |
      --RestfulService
Variable Summary
Method Summary
RestfulService __construct (string $base, [int $expiry = 3600])
void basicAuth ( $username,  $password)
void constructURL ()
void getAttribute (string $xml, [string $collection = NULL], [string $element = NULL], string $attr)
void getAttributes (string $xml, [string $collection = NULL], [string $element = NULL])
void getRecurseValues ( $xml,  &$data, [ $parent = ""])
void getValue (string $xml, [string $collection = NULL], [string $element = NULL])
void getValues (string $xml, [string $collection = NULL], [string $element = NULL])
void httpHeader ( $header)
void request ([ $subURL = ''], [ $method = "GET"], [ $data = null], [ $headers = null])
void searchAttributes (string $xml, [string $node = NULL])
void searchValue (string $xml, [string $node = NULL])
void setQueryString ([array $params = NULL])
Variables
mixed $authPassword (line 17)
  • access: protected
mixed $authUsername (line 17)
  • access: protected
mixed $baseURL (line 10)
  • access: protected
mixed $cache_expire (line 15)
  • access: protected
mixed $checkErrors (line 14)
  • access: protected
mixed $customHeaders = array() (line 18)
  • access: protected
mixed $errorTag (line 13)
  • access: protected
mixed $queryString (line 11)
  • access: protected
mixed $rawXML (line 12)
  • access: protected

Inherited Variables

Inherited from ViewableData

ViewableData::$casting
ViewableData::$castingHelperPair_cache
ViewableData::$customisedObj
ViewableData::$failover
ViewableData::$iteratorPos
ViewableData::$iteratorTotalItems
ViewableData::$namedAs
ViewableData::$parent
ViewableData::$_natural_cache
ViewableData::$_object_cache
ViewableData::$_xml_cache

Inherited from Object

Object::$builtInMethods
Object::$class
Object::$classConstructed
Object::$extensions
Object::$extension_instances
Object::$extraMethods
Object::$extraStatics
Object::$statics
Object::$static_cached
Methods
Constructor __construct (line 25)

Creates a new restful service.

RestfulService __construct (string $base, [int $expiry = 3600])
  • string $base: Base URL of the web service eg: api.example.com
  • int $expiry: Set the cache expiry interva. Defaults to 1 hour (3600 seconds)

Redefinition of:
Object::__construct()
basicAuth (line 41)

Set basic authentication

void basicAuth ( $username,  $password)
  • $username
  • $password
constructURL (line 53)
  • access: protected
void constructURL ()
getAttribute (line 167)

Gets an attribute of a particular element.

  • access: public
void getAttribute (string $xml, [string $collection = NULL], [string $element = NULL], string $attr)
  • string $xml: The source xml to parse, this could be the original response received.
  • string $collection: The name of the parent node which wraps the element, if available
  • string $element: The element we need to extract the attribute
  • string $attr: The name of the attribute
getAttributes (line 136)

Gets attributes as an array, of a particular type of element.

Example : <photo id="2636" owner="123" secret="ab128" server="2"> returns id, owner,secret and sever attribute values of all such photo elements.

  • access: public
void getAttributes (string $xml, [string $collection = NULL], [string $element = NULL])
  • string $xml: The source xml to parse, this could be the original response received.
  • string $collection: The name of parent node which wraps the elements, if available
  • string $element: The element we need to extract the attributes.
getRecurseValues (line 212)
  • access: protected
void getRecurseValues ( $xml,  &$data, [ $parent = ""])
  • $xml
  • &$data
  • $parent
getValue (line 243)

Gets a single node value.

void getValue (string $xml, [string $collection = NULL], [string $element = NULL])
  • string $xml: The source xml to parse, this could be the original response received.
  • string $collection: The name of parent node which wraps the elements, if available
  • string $element: The element we need to extract the node value.
getValues (line 192)

Gets set of node values as an array.

When you get to the depth in the hierachchy use node_child_subchild syntax to get the value.

  • access: public
void getValues (string $xml, [string $collection = NULL], [string $element = NULL])
  • string $xml: The the source xml to parse, this could be the original response received.
  • string $collection: The name of parent node which wraps the elements, if available
  • string $element: The element we need to extract the node values.
httpHeader (line 49)

Set a custom HTTP header

void httpHeader ( $header)
  • $header
request (line 66)

Makes a request to the RESTful server, and return a RestfulService_Response object for parsing of the result.

  • todo: Better POST, PUT, DELETE, and HEAD support
  • todo:

    Pass the response headers to RestfulService_Response

    This is a replacement of connect().

  • todo: Caching of requests - probably only GET and HEAD requestst
  • todo: JSON support in RestfulService_Response
  • access: public
void request ([ $subURL = ''], [ $method = "GET"], [ $data = null], [ $headers = null])
  • $subURL
  • $method
  • $data
  • $headers
searchAttributes (line 273)

Searches for a node in document tree and returns its attributes.

void searchAttributes (string $xml, [string $node = NULL])
  • string $xml: the source xml to parse, this could be the original response received.
  • string $node: Node to search for
searchValue (line 260)

Searches for a node in document tree and returns it value.

void searchValue (string $xml, [string $node = NULL])
  • string $xml: source xml to parse, this could be the original response received.
  • string $node: Node to search for
setQueryString (line 34)

Sets the Query string parameters to send a request.

void setQueryString ([array $params = NULL])
  • array $params: An array passed with necessary parameters.

Inherited Methods

Inherited From ViewableData

ViewableData::ATT_val()
ViewableData::BaseHref()
ViewableData::buildCastingHelperCache()
ViewableData::cachedCall()
ViewableData::castingHelper()
ViewableData::castingHelperPair()
ViewableData::castingObjectCreator()
ViewableData::castingObjectCreatorPair()
ViewableData::CSSClasses()
ViewableData::CurrentMember()
ViewableData::CurrentPage()
ViewableData::customise()
ViewableData::Debug()
ViewableData::defineMethods()
ViewableData::escapeTypeForField()
ViewableData::Even()
ViewableData::EvenOdd()
ViewableData::First()
ViewableData::FirstLast()
ViewableData::getField()
ViewableData::getIterator()
ViewableData::getXMLValues()
ViewableData::hasField()
ViewableData::HasPerm()
ViewableData::hasValue()
ViewableData::i18nLocale()
ViewableData::IsAjax()
ViewableData::iteratorProperties()
ViewableData::JS_val()
ViewableData::Last()
ViewableData::Me()
ViewableData::Middle()
ViewableData::MiddleString()
ViewableData::obj()
ViewableData::Odd()
ViewableData::Pos()
ViewableData::RAW_val()
ViewableData::renderWith()
ViewableData::SecurityID()
ViewableData::setCustomisedObj()
ViewableData::setField()
ViewableData::SQL_val()
ViewableData::ThemeDir()
ViewableData::Top()
ViewableData::TotalItems()
ViewableData::val()
ViewableData::XML_val()
ViewableData::__get()
ViewableData::__isset()
ViewableData::__set()

Inherited From Object

Object::__construct()
Object::addMethodsFrom()
Object::addStaticVars()
Object::addWrapperMethod()
Object::add_extension()
Object::allMethodNames()
Object::buildMethodList()
Object::cacheToFile()
Object::cacheToFileWithArgs()
Object::create()
Object::createMethod()
Object::defineMethods()
Object::exists()
Object::extend()
Object::extInstance()
Object::getCustomClass()
Object::hasExtension()
Object::hasMethod()
Object::invokeWithExtensions()
Object::is_a()
Object::loadCache()
Object::parentClass()
Object::sanitiseCachename()
Object::saveCache()
Object::set_stat()
Object::set_uninherited()
Object::stat()
Object::strong_create()
Object::uninherited()
Object::useCustomClass()
Object::__call()
Object::__toString()
blog comments powered by Disqus

Documentation generated on Sun, 19 Oct 2008 06:45:17 +1300 by phpDocumentor 1.3.2