SilverStripe 2.4 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
Version: master
  • master
  • 3.1
  • 3.0
  • 2.4
  • tagfield

Packages

  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • publishers
    • reports
    • security
    • tasks
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • installer
  • None
  • PHP
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets

Classes

  • RestfulService
  • RestfulService_Response
  • RSSFeed
  • RSSFeed_Entry
  • SapphireSoapServer
  • SS_HTMLValue
  • VersionedRestfulServer

Class RestfulService

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.org/doku.php?id=restfulservice

Object
Extended by ViewableData implements IteratorAggregate
Extended by RestfulService
Package: sapphire\integration
Located at sapphire/api/RestfulService.php

Methods summary

public static
# set_default_proxy( string $proxy, integer $port = 80, string $user = "", string $password = "", boolean $socks = false )

Sets default proxy settings for outbound RestfulService connections

Sets default proxy settings for outbound RestfulService connections

Parameters

$proxy
string
$proxy The URL of the proxy to use.
$port
integer
$port Proxy port
$user
string
$user The proxy auth user name
$password
string
$password The proxy auth password
$socks
boolean
$socks Set true to use socks5 proxy instead of http
public
# __construct( string $base, integer $expiry = 3600 )

Creates a new restful service.

Creates a new restful service.

Parameters

$base
string
$base Base URL of the web service eg: api.example.com
$expiry
integer
$expiry Set the cache expiry interva. Defaults to 1 hour (3600 seconds)

Overrides

Object::__construct
public
# setQueryString( array $params = NULL )

Sets the Query string parameters to send a request.

Sets the Query string parameters to send a request.

Parameters

$params
array
$params An array passed with necessary parameters.
public
# setProxy( string $proxy, integer $port = 80, string $user = "", string $password = "", boolean $socks = false )

Set proxy settings for this RestfulService instance

Set proxy settings for this RestfulService instance

Parameters

$proxy
string
$proxy The URL of the proxy to use.
$port
integer
$port Proxy port
$user
string
$user The proxy auth user name
$password
string
$password The proxy auth password
$socks
boolean
$socks Set true to use socks5 proxy instead of http
public
# basicAuth( mixed $username, mixed $password )

Set basic authentication

Set basic authentication

public
# httpHeader( mixed $header )

Set a custom HTTP header

Set a custom HTTP header

protected
# constructURL( )
public
# connect( mixed $subURL = '' )

Deprecated

Use RestfulService::request()
public RestfulService_Response
# request( mixed $subURL = '', mixed $method = "GET", mixed $data = null, mixed $headers = null, mixed $curlOptions = array() )

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

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

Returns

RestfulService_Response
- If curl request produces error, the returned response's status code will be 500
public
# getAbsoluteRequestURL( string $subURL )

Returns a full request url

Returns a full request url

Parameters

$subURL
string
public
# getAttributes( string $xml, string $collection = NULL, string $element = NULL )

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.

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.

Parameters

$xml
string
$xml The source xml to parse, this could be the original response received.
$collection
string
$collection The name of parent node which wraps the elements, if available
$element
string
$element The element we need to extract the attributes.
public
# getAttribute( string $xml, string $collection = NULL, string $element = NULL, string $attr )

Gets an attribute of a particular element.

Gets an attribute of a particular element.

Parameters

$xml
string
$xml The source xml to parse, this could be the original response received.
$collection
string
$collection The name of the parent node which wraps the element, if available
$element
string
$element The element we need to extract the attribute
$attr
string
$attr The name of the attribute
public
# getValues( string $xml, string $collection = NULL, string $element = NULL )

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.

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.

Parameters

$xml
string
$xml The the source xml to parse, this could be the original response received.
$collection
string
$collection The name of parent node which wraps the elements, if available
$element
string
$element The element we need to extract the node values.
protected
# getRecurseValues( mixed $xml, mixed & $data, mixed $parent = "" )
public
# getValue( string $xml, string $collection = NULL, string $element = NULL )

Gets a single node value.

Gets a single node value.

Parameters

$xml
string
$xml The source xml to parse, this could be the original response received.
$collection
string
$collection The name of parent node which wraps the elements, if available
$element
string
$element The element we need to extract the node value.
public
# searchValue( string $xml, string $node = NULL )

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

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

Parameters

$xml
string
$xml source xml to parse, this could be the original response received.
$node
string
$node Node to search for
public
# searchAttributes( string $xml, string $node = NULL )

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

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

Parameters

$xml
string
$xml the source xml to parse, this could be the original response received.
$node
string
$node Node to search for

Methods inherited from ViewableData

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

Methods inherited from Object

__call(), __toString(), addMethodsFrom(), addStaticVars(), addWrapperMethod(), add_extension(), add_static_var(), allMethodNames(), cacheToFile(), cacheToFileWithArgs(), clearCache(), combined_static(), create(), createMethod(), create_from_string(), exists(), extInstance(), extend(), getCustomClass(), getExtensionInstance(), getExtensionInstances(), get_extensions(), get_static(), hasExtension(), hasMethod(), has_extension(), invokeWithExtensions(), is_a(), loadCache(), parentClass(), parse_class_spec(), remove_extension(), sanitiseCachename(), saveCache(), set_stat(), set_static(), set_uninherited(), stat(), strong_create(), uninherited(), uninherited_static(), useCustomClass()

Magic methods summary

Properties summary

protected mixed $baseURL
#
protected mixed $queryString
#
protected mixed $errorTag
#
protected mixed $checkErrors
#
protected mixed $cache_expire
#
protected mixed $authUsername
#
protected mixed $authPassword
#
protected array $customHeaders
#
protected mixed $proxy
#
protected static mixed $default_proxy
#

Properties inherited from ViewableData

$casting, $customisedObject, $default_cast, $failover, $iteratorPos, $iteratorTotalItems

Properties inherited from Object

$class, $extension_instances, $extensions

Comments

Comment policy: Please use comments for tips and corrections about the described functionality. Comments are moderated, we reserve the right to remove comments that are inappropriate or are no longer relevant.
Use the Silverstripe Forum to ask questions.
blog comments powered by Disqus
SilverStripe 2.4 API Docs API documentation generated by ApiGen 2.8.0