model/modx/rest/modrestcurlclient.class.php
- package
- modx
- subpackage
- rest
- Classes
- modRestCurlClient
- modRestArrayToXML
Description
\modRestArrayToXML
Description
Utility class for array-to-XML transformations.
Methods
isAssoc
isAssoc(
mixed $array
)
:
boolean
Determine if a variable is an associative array
Arguments
- $array
- mixed
The variable to check
Output
- boolean
- True if is an array
Details
- visibility
- public
- final
- false
- static
- true
- static
toArray
toArray(
string $xml
)
:
array
Convert an XML document to a multi dimensional array Pass in an XML document (or SimpleXMLElement object) and this recrusively loops through and builds a representative array
Arguments
- $xml
- string
- XML document - can optionally be a SimpleXMLElement object
Output
- array
- ARRAY
Details
- visibility
- public
- final
- false
- static
- true
toXML
toXML(
array $data, string $rootNodeName
=
ResultSet, \SimpleXMLElement $xml
=
null
)
:
string
The main function for converting to an XML document.
Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
Arguments
- $data
- array
- $rootNodeName
- string
- what you want the root node to be - defaultsto data. - $xml
- \SimpleXMLElement
- should only be used recursively
Output
- string
- XML
Details
- visibility
- public
- final
- false
- static
- true
\modRestCurlClient
- Extends from
- \modRestClient
- package
- modx
- subpackage
- rest
- Methods
- __construct
- request
- setAuth
- setOptions
- setProxy
- setUrl
Description
Handles REST requests through a cURL-based client
Methods
__construct
__construct(
\modX $modx, array $config
=
array
)
:
\modRestClient
The constructor for the modRestClient class. Assigns a modX instance reference and sets up the basic config array.
Arguments
- $modx
- \modX
A reference to the modX object - $config
- array
An array of configuration options
Output
Details
- visibility
- public
- final
- false
- static
- false
request
request(
string $host, string $path, string $method
=
GET, array $params
=
array, array $options
=
array
)
:
\modRestResponse
Extends modRestClient::request to provide cURL specific request handling
Arguments
- $host
- string
The host of the REST server. - $path
- string
The path to request to on the REST server. - $method
- string
The HTTP method to use for the request. May be GET, PUT or POST. - $params
- array
An array of parameters to send with the request. - $options
- array
An array of options to pass to the request.
Output
- \modRestResponse
- The response object.
Details
- visibility
- public
- final
- false
- static
- false
setAuth
setAuth(
resource $ch, array $options
=
array
)
:
boolean
Set up authentication configuration , if specified, to be used with REST request.
Arguments
- $ch
- resource
The cURL connection resource. - $options
- array
An array of options
Output
- boolean
- True if authentication was used.
Details
- visibility
- public
- final
- false
- static
- false
setOptions
setOptions(
resource $ch, array $options
=
array
)
:
Set up cURL-specific options
Arguments
- $ch
- resource
The cURL connection resource - $options
- array
An array of options
Details
- visibility
- public
- final
- false
- static
- false
setProxy
setProxy(
resource $ch, array $options
=
array
)
:
boolean
Set up proxy configuration , if specified, to be used with REST request.
Arguments
- $ch
- resource
The cURL connection resource. - $options
- array
An array of options
Output
- boolean
- True if the proxy was setup.
Details
- visibility
- public
- final
- false
- static
- false
setUrl
setUrl(
resource $ch, string $host, string $path, string $method
=
GET, array $params
=
array, array $options
=
array
)
:
boolean
Configure and set the URL to use, along with any request parameters.
Arguments
- $ch
- resource
The cURL connection resource - $host
- string
The host to send the request to - $path
- string
The path of the request - $method
- string
The method of the request (GET/POST) - $params
- array
An array of request parameters to attach to the URL - $options
- array
An array of options when setting the URL
Output
- boolean
- Whether or not the URL was set
Details
- visibility
- public
- final
- false
- static
- false
- see
- modRestClient::request for parameter documentation.