\WebApiClient
An object that acts as a client to a web API of some sort.
The WebApiClient takes in a mapping of method calls of the form
auth => Whether the user needs to be authenticted
url => The URL to call. This may have placeholders in it (marked as {enclosed} items) which will be replaced
by any arguments in the passed in args array that match these keys.
enctype => What encoding to use when calling this method (defaults to Zend_Http_Client::ENC_URLENCODED)
contentType => Whether to use a specific content type for the request (alfresco sometimes needs
a specific content type eg application/cmisquery+xml)
return => The expected response; this could be a single object (eg cmisobject) or a list of objects (cmislist)
alternatively, it could be raw XML. The returned item will have an implementation object looked
up the "returnHandlers" map, to see if it needs to be handled in a particular way, in which
case handling the returned value will be passed off to it.
params => The names of parameters that could be passed through in the 'args' map.
cache => Whether this method should be cached, and how long for. Only GET requests can be cached
Note that the "callMethod" method is separated out into several submethods to provide for override
points for implementing a specific API
- Author: Marcus Nyeholt <marcus@silverstripe.com.au>
Synopsis
- // members
- public static integer $cache_length = 1200;
- protected String $baseUrl;
- protected $methods;
- protected $globalParams = NULL;
- protected array $returnHandlers = ;
- protected boolean $useCookies = false;
- protected boolean $maintainSession = false;
- protected $authInfo;
- protected Zend_Http_Client $httpClient = NULL;
- // methods
- public void setBaseUrl()
- public void getBaseUrl()
- public void setMethods()
- public void setGlobalParams()
- public void setGlobalParam()
- public array addReturnHandler()
- public void setUseCookies()
- public void setMaintainSession()
- public void setAuthInfo()
- public void __construct()
- public void __call()
- public mixed callMethod()
- public mixed callUrl()
- protected Zend_Http_Client getClient()
Tasks
Line | Task |
---|---|
391 | For some reason the Alfresco client goes into an infinite loop when returning |
Members
protected
- $authInfo
—
array
Basic HTTP Auth details - $baseUrl
—
String
The base URL to use for all the calls - $globalParams
—
array
An array of parameters that should ALWAYS be passed through on each request. - $httpClient
—
Zend_Http_Client
The HTTP Client being used during the life of this request - $maintainSession
- $methods
- $returnHandlers
- $useCookies
—
boolean
Whether or not to persist cookies (eg in a login situation
public
- $cache_length
Methods
protected
- getClient() — Create and return the http client, defined in a separate method for testing purposes
public
- __construct() — Create a new webapi client
- __call()
- addReturnHandler() — Adds a new return handler to the list of handlers.
- callMethod() — Call a method with the passed in arguments
- callUrl() — Call a URL directly, without it being mapped to a configured web method.
- getBaseUrl()
- setAuthInfo()
- setBaseUrl()
- setGlobalParam() — Set a single param
- setGlobalParams() — Sets the global parameters
- setMaintainSession()
- setMethods() — The methods to call
- setUseCookies()