core/model/modx/rest/modrestcurlclient.class.php
- Package
- modx
- Subpackage
- rest
\modRestArrayToXML
Utility class for array-to-XML transformations.
Methods
isAssoc(
mixed $array
)
:
boolean
Determine if a variable is an associative array
Name | Type | Description |
---|---|---|
$array | mixed | The variable to check |
Type | Description |
---|---|
boolean | True if is an array |
- Static
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
Name | Type | Description |
---|---|---|
$xml | string |
|
Type | Description |
---|---|
array | ARRAY |
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.
Name | Type | Description |
---|---|---|
$data | array | |
$rootNodeName | string |
|
$xml | \SimpleXMLElement |
|
Type | Description |
---|---|
string | XML |
\modRestCurlClient
Handles REST requests through a cURL-based client
- Parent(s)
- \modRestClient
Constants
OPT_PATH
= 'path'
- Const
- The path of the request
- Inherited_from
- \modRestClient::OPT_PATH
OPT_PORT
= 'port'
- Const
- The port of the request
- Inherited_from
- \modRestClient::OPT_PORT
OPT_RESPONSE_CLASS
= 'restResponse.class'
- Const
- The response class to use when generating the response object
- Inherited_from
- \modRestClient::OPT_RESPONSE_CLASS
OPT_TIMEOUT
= 'timeout'
- Const
- The number of seconds before the request times out
- Inherited_from
- \modRestClient::OPT_TIMEOUT
OPT_USERAGENT
= 'userAgent'
- Const
- The user-agent sent in the request
- Inherited_from
- \modRestClient::OPT_USERAGENT
OPT_USERPWD
= 'userpwd'
- Const
- The user password to send with the request
- Inherited_from
- \modRestClient::OPT_USERPWD
OPT_AUTHTYPE
= 'authtype'
- Const
- The authentication type for the request
- Inherited_from
- \modRestClient::OPT_AUTHTYPE
Properties
array
$config= 'array()'
array()
Details- Type
- array
- Access
- public
- Inherited_from
- \modRestClient::$$config
\modRestClient
$conn= 'null'
null
Details- Type
- \modRestClient
- Access
- public
- Inherited_from
- \modRestClient::$$conn
\modX
$modx= 'null'
null
Details- Type
- \modX
- Access
- public
- Inherited_from
- \modRestClient::$$modx
\modRestResponse
$response= 'null'
null
Details- Type
- \modRestResponse
- Access
- public
- Inherited_from
- \modRestClient::$$response
string
$responseType= ''xml''
'xml'
Details- Type
- string
- Access
- public
- Inherited_from
- \modRestClient::$$responseType
Methods
__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.
Name | Type | Description |
---|---|---|
$modx | \modX | A reference to the modX object |
$config | array | An array of configuration options |
Type | Description |
---|---|
\modRestClient |
getConnection(
)
:
boolean
Get the connection class for the client. Defaults to cURL, then fsockopen. If neither exists, returns false.
Inherited from: \modRestClient::getConnection()Type | Description |
---|---|
boolean | True if a connection can be made. |
- Access
- public
request(
string $host, string $path, string $method
=
'GET', array $params
=
array(), array $options
=
array()
)
:
\modRestResponse
Extends modRestClient::request to provide cURL specific request handling
Name | Type | Description |
---|---|---|
$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. |
Type | Description |
---|---|
\modRestResponse | The response object. |
setAuth(
resource $ch, array $options
=
array()
)
:
boolean
Set up authentication configuration , if specified, to be used with REST request.
Name | Type | Description |
---|---|---|
$ch | resource | The cURL connection resource. |
$options | array | An array of options |
Type | Description |
---|---|
boolean | True if authentication was used. |
setOptions(
resource $ch, array $options
=
array()
)
:
void
Set up cURL-specific options
Name | Type | Description |
---|---|---|
$ch | resource | The cURL connection resource |
$options | array | An array of options |
setProxy(
resource $ch, array $options
=
array()
)
:
boolean
Set up proxy configuration , if specified, to be used with REST request.
Name | Type | Description |
---|---|---|
$ch | resource | The cURL connection resource. |
$options | array | An array of options |
Type | Description |
---|---|
boolean | True if the proxy was setup. |
setResponseType(
string $type
)
:
void
Name | Type | Description |
---|---|---|
$type | string | The type to set, either json or xml |
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.
Name | Type | Description |
---|---|---|
$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 |
Type | Description |
---|---|
boolean | Whether or not the URL was set |
xml2array(
\SimpleXMLElement $obj, array $arr
)
:
boolean
Translates a SimpleXMLElement object into an array.
Inherited from: \modRestClient::xml2array()Name | Type | Description |
---|---|---|
$obj | \SimpleXMLElement | |
$arr | array | &$arr The reference array to store the results in. |
Type | Description |
---|---|
boolean | True if successful. |
- Access
- public