\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
Synopsis
class RestfulService
extends ViewableData
implements
Flushable
{
- // members
- protected $baseURL;
- protected $queryString;
- protected $errorTag;
- protected $checkErrors;
- protected $cache_expire;
- protected $authUsername;
- protected array $customHeaders = ;
- protected $proxy;
- private static $default_proxy;
- private static array $default_curl_options = ;
- private static bool $flush = false;
- // methods
- public static void flush()
- public static void set_default_curl_option()
- public static void set_default_curl_options()
- public static void set_default_proxy()
- public void __construct()
- public void setQueryString()
- public void setProxy()
- public void basicAuth()
- public void httpHeader()
- protected void constructURL()
- public RestfulService_Response request()
- public RestfulService_Response curlRequest()
- protected string getBasicAuthString()
- protected void generateCacheKey()
- protected string getCachePath()
- protected RestfulService_Response extractResponse()
- protected array parseRawHeaders()
- public void getAbsoluteRequestURL()
- public void getAttributes()
- public void getAttribute()
- public void getValues()
- protected void getRecurseValues()
- public void getValue()
- public void searchValue()
- public void searchAttributes()
Hierarchy
Extends
- ViewableData
Implements
- Flushable
Tasks
Line | Task |
---|---|
170+ | Better POST, PUT, DELETE, and HEAD support |
170+ | Caching of requests - probably only GET and HEAD requestst |
170+ | JSON support in RestfulService_Response |
170+ | Pass the response headers to RestfulService_Response This is a replacement of {@link connect()}. |
Members
private
- $default_curl_options — array
- $default_proxy — array
- $flush — bool
protected
- $authUsername
- $baseURL
- $cache_expire
- $checkErrors
- $customHeaders
- $errorTag
- $proxy
- $queryString
Methods
protected
- constructURL()
- extractResponse() — Extracts the response body and headers from a full curl response
- generateCacheKey() — Generate a cache key based on any cache data sent. The cache data can be any type
- getBasicAuthString() — A function to return the auth string. This helps consistency through the class but also allows tests to pull it out when generating the expected cache keys
- getCachePath() — Generate the cache path
- getRecurseValues()
- parseRawHeaders() — Takes raw headers and parses them to turn them to an associative array
public
- __construct() — Creates a new restful service.
- basicAuth() — Set basic authentication
- curlRequest() — Actually performs a remote service request using curl. This is used by {@link RestfulService::request()}.
- flush() — Triggered early in the request when someone requests a flush.
- getAbsoluteRequestURL() — Returns a full request url
- getAttribute() — Gets an attribute of a particular element.
- getAttributes() — Gets attributes as an array, of a particular type of element.
- getValue() — Gets a single node value.
- getValues() — Gets set of node values as an array.
- httpHeader() — Set a custom HTTP header
- request() — Makes a request to the RESTful server, and return a {@link RestfulService_Response} object for parsing of the result.
- searchAttributes() — Searches for a node in document tree and returns its attributes.
- searchValue() — Searches for a node in document tree and returns it value.
- setProxy() — Set proxy settings for this RestfulService instance
- setQueryString() — Sets the Query string parameters to send a request.
- set_default_curl_option() — set a curl option that will be applied to all requests as default {@see http://php.net/manual/en/function.curl-setopt.php#refsect1-function.curl-setopt-parameters}
- set_default_curl_options() — set many defauly curl options at once
- set_default_proxy() — Sets default proxy settings for outbound RestfulService connections