core/model/modx/rest/modrestsockclient.class.php
- Package
- modx
- Subpackage
- rest
\modRestSockClient
The basic REST client for handling REST requests
- 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.
Inherited from: \modRestClient::__construct()Name | Type | Description |
---|---|---|
$modx | \modX | &$modx A reference to the modX instance. |
$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 socket-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. |
- Todo
- Ensure this strips whitespace that prevents this class from working
setResponseType(
string $type
)
:
void
Name | Type | Description |
---|---|---|
$type | string | The type to set, either json or xml |
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