Client
in package
uses
DeprecationLogger
Used to represent a client of an XML-RPC server.
Table of Contents
Constants
- OPT_ACCEPTED_CHARSET_ENCODINGS = 'accepted_charset_encodings'
- OPT_ACCEPTED_COMPRESSION = 'accepted_compression'
- OPT_AUTH_TYPE = 'authtype'
- OPT_CA_CERT = 'cacert'
- OPT_CA_CERT_DIR = 'cacertdir'
- OPT_CERT = 'cert'
- OPT_CERT_PASS = 'certpass'
- OPT_COOKIES = 'cookies'
- OPT_DEBUG = 'debug'
- OPT_EXTRA_CURL_OPTS = 'extracurlopts'
- OPT_EXTRA_HEADERS = 'extra_headers'
- OPT_EXTRA_SOCKET_OPTS = 'extrasockopts'
- OPT_KEEPALIVE = 'keepalive'
- OPT_KEY = 'key'
- OPT_KEY_PASS = 'keypass'
- OPT_NO_MULTICALL = 'no_multicall'
- OPT_PASSWORD = 'password'
- OPT_PROXY = 'proxy'
- OPT_PROXY_AUTH_TYPE = 'proxy_authtype'
- OPT_PROXY_PASS = 'proxy_pass'
- OPT_PROXY_PORT = 'proxyport'
- OPT_PROXY_USER = 'proxy_user'
- OPT_REQUEST_CHARSET_ENCODING = 'request_charset_encoding'
- OPT_REQUEST_COMPRESSION = 'request_compression'
- OPT_RETURN_TYPE = 'return_type'
- OPT_SSL_VERSION = 'sslversion'
- OPT_TIMEOUT = 'timeout'
- OPT_USE_CURL = 'use_curl'
- OPT_USER_AGENT = 'user_agent'
- OPT_USERNAME = 'username'
- OPT_VERIFY_HOST = 'verifyhost'
- OPT_VERIFY_PEER = 'verifypeer'
- USE_CURL_ALWAYS = 1
- USE_CURL_AUTO = 2
- USE_CURL_NEVER = 0
Properties
- $errno : int
- $errstr : string
- $method : string
- $path : string
- $port : int
- $server : string
- $accepted_charset_encodings : array<string|int, string>
- $accepted_compression : array<string|int, mixed>
- $authtype : int
- $cacert : string
- $cacertdir : string
- $cert : string
- $certpass : string
- $cookies : array<string|int, mixed>
- $debug : int
- $errno : int
- $errstr : string
- $extra_headers : array<string|int, string>
- Additional headers to be included in the requests.
- $extracurlopts : array<string|int, mixed>
- $extrasockopts : array<string|int, mixed>
- $keepalive : bool
- $key : string
- $keypass : string
- $method : string
- $no_multicall : bool
- $options : array<string|int, mixed>
- $password : string
- $path : string
- $port : int
- $proxy : string
- $proxy_authtype : int
- $proxy_pass : string
- $proxy_user : string
- $proxyport : int
- $request_charset_encoding : string
- $request_compression : string|null
- $requestClass : string
- $responseClass : string
- $return_type : string
- $server : string
- $sslversion : int
- $timeout : int
- $use_curl : int
- $user_agent : string
- $username : string
- $verifyhost : int
- $verifypeer : bool
Methods
- __construct() : mixed
- __get() : mixed
- __isset() : mixed
- __set() : mixed
- __unset() : mixed
- getOption() : mixed
- getOptions() : array<string|int, mixed>
- Returns the complete list of Client options, with their value.
- getUrl() : string|int
- multicall() : array<string|int, Response>
- Send an array of requests and return an array of responses.
- send() : Response|array<string|int, Response>
- Send an xml-rpc request to the server.
- setAcceptedCompression() : $this
- Enables/disables reception of compressed xml-rpc responses.
- setCaCertificate() : $this
- Add a CA certificate to verify server with in SSL-enabled communication when SetSSLVerifypeer has been set to TRUE.
- setCertificate() : $this
- Set the optional certificate and passphrase used in SSL-enabled communication with a remote server.
- setCookie() : $this
- Adds a cookie to list of cookies that will be sent to server with every further request (useful e.g. for keeping session info outside the xml-rpc payload).
- setCredentials() : $this
- Sets the username and password for authorizing the client to the server.
- setCurlOptions() : $this
- Directly set cURL options, for extra flexibility (when in cURL mode).
- setDebug() : $this
- Enable/disable the echoing to screen of the xml-rpc responses received. The default is not to output anything.
- setKey() : $this
- Set attributes for SSL communication: private SSL key.
- setOption() : $this
- setOptions() : $this
- setProxy() : $this
- Set proxy info.
- setRequestCompression() : $this
- Enables/disables http compression of xml-rpc request.
- setSSLVerifyHost() : $this
- Set attributes for SSL communication: verify the remote host's SSL certificate's common name (CN).
- setSSLVerifyPeer() : $this
- Set attributes for SSL communication: verify the remote host's SSL certificate, and cause the connection to fail if the cert verification fails.
- setSSLVersion() : $this
- Set attributes for SSL communication: SSL version to use. Best left at 0 (default value): let cURL decide
- setUseCurl() : $this
- setUserAgent() : $this
- Set user-agent string that will be used by this client instance in http headers sent to the server.
- createCURLHandle() : CurlHandle|resource|false
- logDeprecation() : mixed
- logDeprecationUnlessCalledBy() : void
- prepareCurlHandle() : false|CurlHandle|resource
- sendPayloadCURL() : Response
- sendPayloadHTTP10() : Response
- sendPayloadHTTPS() : Response
- sendPayloadSocket() : Response
- sendViaCURL() : Response
- Contributed by Justin Miller Requires curl to be built into PHP NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers!
- sendViaSocket() : Response
- _try_multicall() : array<string|int, Response>|Response
- Attempt to boxcar $reqs via system.multicall.
Constants
OPT_ACCEPTED_CHARSET_ENCODINGS
public
mixed
OPT_ACCEPTED_CHARSET_ENCODINGS
= 'accepted_charset_encodings'
OPT_ACCEPTED_COMPRESSION
public
mixed
OPT_ACCEPTED_COMPRESSION
= 'accepted_compression'
OPT_AUTH_TYPE
public
mixed
OPT_AUTH_TYPE
= 'authtype'
OPT_CA_CERT
public
mixed
OPT_CA_CERT
= 'cacert'
OPT_CA_CERT_DIR
public
mixed
OPT_CA_CERT_DIR
= 'cacertdir'
OPT_CERT
public
mixed
OPT_CERT
= 'cert'
OPT_CERT_PASS
public
mixed
OPT_CERT_PASS
= 'certpass'
OPT_COOKIES
public
mixed
OPT_COOKIES
= 'cookies'
OPT_DEBUG
public
mixed
OPT_DEBUG
= 'debug'
OPT_EXTRA_CURL_OPTS
public
mixed
OPT_EXTRA_CURL_OPTS
= 'extracurlopts'
OPT_EXTRA_HEADERS
public
mixed
OPT_EXTRA_HEADERS
= 'extra_headers'
OPT_EXTRA_SOCKET_OPTS
public
mixed
OPT_EXTRA_SOCKET_OPTS
= 'extrasockopts'
OPT_KEEPALIVE
public
mixed
OPT_KEEPALIVE
= 'keepalive'
OPT_KEY
public
mixed
OPT_KEY
= 'key'
OPT_KEY_PASS
public
mixed
OPT_KEY_PASS
= 'keypass'
OPT_NO_MULTICALL
public
mixed
OPT_NO_MULTICALL
= 'no_multicall'
OPT_PASSWORD
public
mixed
OPT_PASSWORD
= 'password'
OPT_PROXY
public
mixed
OPT_PROXY
= 'proxy'
OPT_PROXY_AUTH_TYPE
public
mixed
OPT_PROXY_AUTH_TYPE
= 'proxy_authtype'
OPT_PROXY_PASS
public
mixed
OPT_PROXY_PASS
= 'proxy_pass'
OPT_PROXY_PORT
public
mixed
OPT_PROXY_PORT
= 'proxyport'
OPT_PROXY_USER
public
mixed
OPT_PROXY_USER
= 'proxy_user'
OPT_REQUEST_CHARSET_ENCODING
public
mixed
OPT_REQUEST_CHARSET_ENCODING
= 'request_charset_encoding'
OPT_REQUEST_COMPRESSION
public
mixed
OPT_REQUEST_COMPRESSION
= 'request_compression'
OPT_RETURN_TYPE
public
mixed
OPT_RETURN_TYPE
= 'return_type'
OPT_SSL_VERSION
public
mixed
OPT_SSL_VERSION
= 'sslversion'
OPT_TIMEOUT
public
mixed
OPT_TIMEOUT
= 'timeout'
OPT_USE_CURL
public
mixed
OPT_USE_CURL
= 'use_curl'
OPT_USER_AGENT
public
mixed
OPT_USER_AGENT
= 'user_agent'
OPT_USERNAME
public
mixed
OPT_USERNAME
= 'username'
OPT_VERIFY_HOST
public
mixed
OPT_VERIFY_HOST
= 'verifyhost'
OPT_VERIFY_PEER
public
mixed
OPT_VERIFY_PEER
= 'verifypeer'
USE_CURL_ALWAYS
public
mixed
USE_CURL_ALWAYS
= 1
USE_CURL_AUTO
public
mixed
USE_CURL_AUTO
= 2
USE_CURL_NEVER
public
mixed
USE_CURL_NEVER
= 0
Properties
$errno
public
int
$errno
deprecated - public access left in purely for BC.
$errstr
public
string
$errstr
deprecated - public access left in purely for BC.
$method
public
string
$method
deprecated - public access left in purely for BC. Access via getUrl()/__construct()
$path
public
string
$path
deprecated - public access left in purely for BC. Access via getUrl()/__construct()
$port
public
int
$port
deprecated - public access left in purely for BC. Access via getUrl()/__construct()
$server
public
string
$server
deprecated - public access left in purely for BC. Access via getUrl()/__construct()
$accepted_charset_encodings
protected
array<string|int, string>
$accepted_charset_encodings
= array()
Charset encodings that can be decoded without problems by the client. Value set at constructor time
$accepted_compression
protected
array<string|int, mixed>
$accepted_compression
= array()
List of http compression methods accepted by the client for responses. NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib.
NNB: you can set it to any non-empty array for HTTP11 and HTTPS, since in those cases it will be up to CURL to decide the compression methods it supports. You might check for the presence of 'zlib' in the output of curl_version() to determine whether compression is supported or not
$authtype
protected
int
$authtype
= 1
$cacert
protected
string
$cacert
= ''
$cacertdir
protected
string
$cacertdir
= ''
$cert
protected
string
$cert
= ''
$certpass
protected
string
$certpass
= ''
$cookies
protected
array<string|int, mixed>
$cookies
= array()
$debug
protected
int
$debug
= 0
$errno
will be removed in the future
protected
int
$errno
$errstr
will be removed in the future
protected
string
$errstr
$extra_headers
Additional headers to be included in the requests.
protected
array<string|int, string>
$extra_headers
= array()
$extracurlopts
protected
array<string|int, mixed>
$extracurlopts
= array()
$extrasockopts
protected
array<string|int, mixed>
$extrasockopts
= array()
$keepalive
protected
bool
$keepalive
= false
Whether to use persistent connections for http 1.1 and https. Value set at constructor time.
$key
protected
string
$key
= ''
$keypass
protected
string
$keypass
= ''
$method
protected
string
$method
= 'http'
$no_multicall
protected
bool
$no_multicall
= false
This determines whether the multicall() method will try to take advantage of the system.multicall xml-rpc method to dispatch to the server an array of requests in a single http roundtrip or simply execute many consecutive http calls. Defaults to FALSE, but it will be enabled automatically on the first failure of execution of system.multicall.
$options
protected
static array<string|int, mixed>
$options
= array(self::OPT_ACCEPTED_CHARSET_ENCODINGS, self::OPT_ACCEPTED_COMPRESSION, self::OPT_AUTH_TYPE, self::OPT_CA_CERT, self::OPT_CA_CERT_DIR, self::OPT_CERT, self::OPT_CERT_PASS, self::OPT_COOKIES, self::OPT_DEBUG, self::OPT_EXTRA_CURL_OPTS, self::OPT_EXTRA_SOCKET_OPTS, self::OPT_KEEPALIVE, self::OPT_KEY, self::OPT_KEY_PASS, self::OPT_NO_MULTICALL, self::OPT_PASSWORD, self::OPT_PROXY, self::OPT_PROXY_AUTH_TYPE, self::OPT_PROXY_PASS, self::OPT_PROXY_USER, self::OPT_PROXY_PORT, self::OPT_REQUEST_CHARSET_ENCODING, self::OPT_REQUEST_COMPRESSION, self::OPT_RETURN_TYPE, self::OPT_SSL_VERSION, self::OPT_TIMEOUT, self::OPT_USE_CURL, self::OPT_USER_AGENT, self::OPT_USERNAME, self::OPT_VERIFY_HOST, self::OPT_VERIFY_PEER, self::OPT_EXTRA_HEADERS)
$password
protected
string
$password
= ''
$path
protected
string
$path
$port
protected
int
$port
= 0
$proxy
protected
string
$proxy
= ''
$proxy_authtype
protected
int
$proxy_authtype
= 1
$proxy_pass
protected
string
$proxy_pass
= ''
$proxy_user
protected
string
$proxy_user
= ''
$proxyport
protected
int
$proxyport
= 0
$request_charset_encoding
protected
string
$request_charset_encoding
= ''
The charset encoding that will be used for serializing request sent by the client. It defaults to NULL, which means using US-ASCII and encoding all characters outside the ASCII printable range using their xml character entity representation (this has the benefit that line end characters will not be mangled in the transfer, a CR-LF will be preserved as well as a singe LF). Valid values are 'US-ASCII', 'UTF-8' and 'ISO-8859-1'. For the fastest mode of operation, set your both your app internal encoding and this to UTF-8.
$request_compression
protected
string|null
$request_compression
= ''
Name of compression scheme to be used for sending requests. Either null, 'gzip' or 'deflate'.
$requestClass
protected
static string
$requestClass
= '\PhpXmlRpc\Request'
$responseClass
protected
static string
$responseClass
= '\PhpXmlRpc\Response'
$return_type
protected
string
$return_type
= \PhpXmlRpc\Helper\XMLParser::RETURN_XMLRPCVALS
Decides the content of Response objects returned by calls to send() and multicall(). Valid values are 'xmlrpcvals', 'phpvals' or 'xml'.
Determines whether the value returned inside a Response object as results of calls to the send() and multicall() methods will be a Value object, a plain php value or a raw xml string. Allowed values are 'xmlrpcvals' (the default), 'phpvals' and 'xml'. To allow the user to differentiate between a correct and a faulty response, fault responses will be returned as Response objects in any case. Note that the 'phpvals' setting will yield faster execution times, but some of the information from the original response will be lost. It will be e.g. impossible to tell whether a particular php string value was sent by the server as an xml-rpc string or base64 value.
$server
protected
string
$server
$sslversion
protected
int
$sslversion
= 0
$timeout
protected
int
$timeout
= 0
$use_curl
protected
int
$use_curl
= self::USE_CURL_AUTO
$user_agent
protected
string
$user_agent
Sent to servers in http headers. Value set at constructor time.
$username
protected
string
$username
= ''
$verifyhost
protected
int
$verifyhost
= 2
$verifypeer
protected
bool
$verifypeer
= true
Methods
__construct()
public
__construct(string $path[, string $server = '' ][, int $port = '' ][, string $method = '' ]) : mixed
Parameters
- $path : string
-
either the PATH part of the xml-rpc server URL, or complete server URL (in which case you should use an empty string for all other parameters) e.g. /xmlrpc/server.php e.g. http://phpxmlrpc.sourceforge.net/server.php e.g. https://james:bond@secret.service.com:444/xmlrpcserver?agent=007 e.g. h2://fast-and-secure-services.org/endpoint
- $server : string = ''
-
the server name / ip address
- $port : int = ''
-
the port the server is listening on, when omitted defaults to 80 or 443 depending on protocol used
- $method : string = ''
-
the http protocol variant: defaults to 'http'; 'https', 'http11', 'h2' and 'h2c' can be used if CURL is installed. The value set here can be overridden in any call to $this->send(). Use 'h2' to make the lib attempt to use http/2 over a secure connection, and 'h2c' for http/2 without tls. Note that 'h2c' will not use the h2c 'upgrade' method, and be thus incompatible with any server/proxy not supporting http/2. This is because POST request are not compatible with h2c upgrade.
__get()
public
& __get(mixed $name) : mixed
Parameters
- $name : mixed
__isset()
public
__isset(mixed $name) : mixed
Parameters
- $name : mixed
__set()
public
__set(mixed $name, mixed $value) : mixed
Parameters
- $name : mixed
- $value : mixed
__unset()
public
__unset(mixed $name) : mixed
Parameters
- $name : mixed
getOption()
public
getOption(string $name) : mixed
Parameters
- $name : string
-
see all the OPT_ constants
Tags
getOptions()
Returns the complete list of Client options, with their value.
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getUrl()
public
getUrl([null|int $component = null ]) : string|int
Parameters
- $component : null|int = null
-
allowed values: PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_PATH
Tags
Return values
string|int —Notes: the path component will include query string and fragment; NULL is a valid value for port (in which case the default port for http/https will be used);
multicall()
Send an array of requests and return an array of responses.
public
multicall(array<string|int, Request> $reqs[, mixed $timeout = 0 ][, string $method = '' ][, bool $fallback = true ]) : array<string|int, Response>
Unless $this->no_multicall has been set to true, it will try first to use one single xml-rpc call to server method system.multicall, and revert to sending many successive calls in case of failure. This failure is also stored in $this->no_multicall for subsequent calls. Unfortunately, there is no server error code universally used to denote the fact that multicall is unsupported, so there is no way to reliably distinguish between that and a temporary failure. If you are sure that server supports multicall and do not want to fallback to using many single calls, set the 2np parameter to FALSE.
NB: trying to shoehorn extra functionality into existing syntax has resulted in pretty much convoluted code...
Parameters
- $reqs : array<string|int, Request>
-
an array of Request objects
- $timeout : mixed = 0
- $method : string = ''
-
deprecated. Was: "the http protocol variant to be used. See the details in the docs for the send() method." Please use the constructor to set an http protocol variant.
- $fallback : bool = true
-
deprecated. Was: "w"hen true, upon receiving an error during multicall, multiple single calls will be attempted"
Return values
array<string|int, Response>send()
Send an xml-rpc request to the server.
public
send(Request|array<string|int, Request>|string $req[, int $timeout = 0 ][, string $method = '' ]) : Response|array<string|int, Response>
Parameters
- $req : Request|array<string|int, Request>|string
-
The Request object, or an array of requests for using multicall, or the complete xml representation of a request. When sending an array of Request objects, the client will try to make use of a single 'system.multicall' xml-rpc method call to forward to the server all the requests in a single HTTP round trip, unless $this->no_multicall has been previously set to TRUE (see the multicall method below), in which case many consecutive xml-rpc requests will be sent. The method will return an array of Response objects in both cases. The third variant allows to build by hand (or any other means) a complete xml-rpc request message, and send it to the server. $req should be a string containing the complete xml representation of the request. It is e.g. useful when, for maximal speed of execution, the request is serialized into a string using the native php xml-rpc functions (see http://www.php.net/xmlrpc)
- $timeout : int = 0
-
deprecated. Connection timeout, in seconds, If unspecified, the timeout set with setOption will be used. If that is 0, a platform specific timeout will apply. This timeout value is passed to fsockopen(). It is also used for detecting server timeouts during communication (i.e. if the server does not send anything to the client for $timeout seconds, the connection will be closed).
- $method : string = ''
-
deprecated. Use the same value in the constructor instead. Valid values are 'http', 'http11', 'https', 'h2' and 'h2c'. If left empty, the http protocol chosen during creation of the object will be used. Use 'h2' to make the lib attempt to use http/2 over a secure connection, and 'h2c' for http/2 without tls. Note that 'h2c' will not use the h2c 'upgrade' method, and be thus incompatible with any server/proxy not supporting http/2. This is because POST request are not compatible with h2c upgrade.
Tags
Return values
Response|array<string|int, Response> —Note that the client will always return a Response object, even if the call fails
setAcceptedCompression()
Enables/disables reception of compressed xml-rpc responses.
public
setAcceptedCompression(string $compMethod) : $this
This requires the "zlib" extension to be enabled in your php install. If it is, by default xmlrpc_client instances will enable reception of compressed content. Note that enabling reception of compressed responses merely adds some standard http headers to xml-rpc requests. It is up to the xml-rpc server to return compressed responses when receiving such requests.
Parameters
- $compMethod : string
-
either 'gzip', 'deflate', 'any' or ''
Return values
$thissetCaCertificate()
Add a CA certificate to verify server with in SSL-enabled communication when SetSSLVerifypeer has been set to TRUE.
public
setCaCertificate(string $caCert[, bool $isDir = false ]) : $this
See the php manual page about CURLOPT_CAINFO for more details.
Parameters
- $caCert : string
-
certificate file name (or dir holding certificates)
- $isDir : bool = false
-
set to true to indicate cacert is a dir. defaults to false
Return values
$thissetCertificate()
Set the optional certificate and passphrase used in SSL-enabled communication with a remote server.
public
setCertificate(string $cert[, string $certPass = '' ]) : $this
Note: to retrieve information about the client certificate on the server side, you will need to look into the environment variables which are set up by the webserver. Different webservers will typically set up different variables.
Parameters
- $cert : string
-
the name of a file containing a PEM formatted certificate
- $certPass : string = ''
-
the password required to use it
Return values
$thissetCookie()
Adds a cookie to list of cookies that will be sent to server with every further request (useful e.g. for keeping session info outside the xml-rpc payload).
public
setCookie(string $name[, string $value = '' ][, string $path = '' ][, string $domain = '' ][, int $port = null ]) : $this
NB: by default all cookies set via this method are sent to the server, regardless of path/domain/port. Taking advantage of those values is left to the single developer.
Parameters
- $name : string
-
nb: will not be escaped in the request's http headers. Take care not to use CTL chars or separators!
- $value : string = ''
- $path : string = ''
- $domain : string = ''
- $port : int = null
-
do not use! Cookies are not separated by port
Tags
Return values
$thissetCredentials()
Sets the username and password for authorizing the client to the server.
public
setCredentials(string $user, string $password[, int $authType = 1 ]) : $this
With the default (HTTP) transport, this information is used for HTTP Basic authorization. Note that username and password can also be set using the class constructor. With HTTP 1.1 and HTTPS transport, NTLM and Digest authentication protocols are also supported. To enable them use the constants CURLAUTH_DIGEST and CURLAUTH_NTLM as values for the auth type parameter.
Parameters
- $user : string
-
username
- $password : string
-
password
- $authType : int = 1
-
auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC (basic auth). Note that auth types NTLM and Digest will only work if the Curl php extension is enabled.
Return values
$thissetCurlOptions()
Directly set cURL options, for extra flexibility (when in cURL mode).
public
setCurlOptions(array<string|int, mixed> $options) : $this
use setOption
It allows e.g. to bind client to a specific IP interface / address.
Parameters
- $options : array<string|int, mixed>
Return values
$thissetDebug()
Enable/disable the echoing to screen of the xml-rpc responses received. The default is not to output anything.
public
setDebug(int $level) : $this
The debugging information at level 1 includes the raw data returned from the XML-RPC server it was querying (including bot HTTP headers and the full XML payload), and the PHP value the client attempts to create to represent the value returned by the server. At level 2, the complete payload of the xml-rpc request is also printed, before being sent to the server. At level -1, the Response objects returned by send() calls will not carry information about the http response's cookies, headers and body, which might save some memory
This option can be very useful when debugging servers as it allows you to see exactly what the client sends and the server returns. Never leave it enabled for production!
Parameters
- $level : int
-
values -1, 0, 1 and 2 are supported
Return values
$thissetKey()
Set attributes for SSL communication: private SSL key.
public
setKey(string $key, string $keyPass) : $this
NB: does not work in older php/curl installs. Thanks to Daniel Convissor.
Parameters
- $key : string
-
The name of a file containing a private SSL key
- $keyPass : string
-
The secret password needed to use the private SSL key
Return values
$thissetOption()
public
setOption(string $name, mixed $value) : $this
Parameters
- $name : string
-
see all the OPT_ constants
- $value : mixed
Tags
Return values
$thissetOptions()
public
setOptions(array<string|int, mixed> $options) : $this
Parameters
- $options : array<string|int, mixed>
-
key: any valid option (see all the OPT_ constants)
Tags
Return values
$thissetProxy()
Set proxy info.
public
setProxy(string $proxyHost, string $proxyPort[, string $proxyUsername = '' ][, string $proxyPassword = '' ][, int $proxyAuthType = 1 ]) : $this
NB: CURL versions before 7.11.10 cannot use a proxy to communicate with https servers.
Parameters
- $proxyHost : string
- $proxyPort : string
-
Defaults to 8080 for HTTP and 443 for HTTPS
- $proxyUsername : string = ''
-
Leave blank if proxy has public access
- $proxyPassword : string = ''
-
Leave blank if proxy has public access
- $proxyAuthType : int = 1
-
defaults to CURLAUTH_BASIC (Basic authentication protocol); set to constant CURLAUTH_NTLM to use NTLM auth with proxy (has effect only when the client uses the HTTP 1.1 protocol)
Return values
$thissetRequestCompression()
Enables/disables http compression of xml-rpc request.
public
setRequestCompression(string $compMethod) : $this
use setOption
This requires the "zlib" extension to be enabled in your php install. Take care when sending compressed requests: servers might not support them (and automatic fallback to uncompressed requests is not yet implemented).
Parameters
- $compMethod : string
-
either 'gzip', 'deflate' or ''
Return values
$thissetSSLVerifyHost()
Set attributes for SSL communication: verify the remote host's SSL certificate's common name (CN).
public
setSSLVerifyHost(int $i) : $this
use setOption
Note that support for value 1 has been removed in cURL 7.28.1
Parameters
- $i : int
-
Set to 1 to only the existence of a CN, not that it matches
Return values
$thissetSSLVerifyPeer()
Set attributes for SSL communication: verify the remote host's SSL certificate, and cause the connection to fail if the cert verification fails.
public
setSSLVerifyPeer(bool $i) : $this
use setOption
By default, verification is enabled. To specify custom SSL certificates to validate the server with, use the setCaCertificate method.
Parameters
- $i : bool
-
enable/disable verification of peer certificate
Return values
$thissetSSLVersion()
Set attributes for SSL communication: SSL version to use. Best left at 0 (default value): let cURL decide
public
setSSLVersion(int $i) : $this
use setOption
Parameters
- $i : int
-
see CURL_SSLVERSION_ constants
Return values
$thissetUseCurl()
public
setUseCurl(int $useCurlMode) : $this
use setOption
Parameters
- $useCurlMode : int
-
self::USE_CURL_ALWAYS, self::USE_CURL_AUTO or self::USE_CURL_NEVER
Return values
$thissetUserAgent()
Set user-agent string that will be used by this client instance in http headers sent to the server.
public
setUserAgent(string $agentString) : $this
use setOption
The default user agent string includes the name of this library and the version number.
Parameters
- $agentString : string
Return values
$thiscreateCURLHandle()
protected
createCURLHandle(Request $req, string $method, string $server, int $port, string $path, array<string|int, mixed> $opts) : CurlHandle|resource|false
Parameters
- $req : Request
- $method : string
- $server : string
- $port : int
- $path : string
- $opts : array<string|int, mixed>
-
the keys/values match self::getOptions
Tags
Return values
CurlHandle|resource|falselogDeprecation()
protected
logDeprecation(mixed $message) : mixed
Parameters
- $message : mixed
logDeprecationUnlessCalledBy()
protected
logDeprecationUnlessCalledBy(string $expectedCaller) : void
Parameters
- $expectedCaller : string
-
atm only the method name is supported
prepareCurlHandle()
protected
prepareCurlHandle(mixed $req, mixed $server, mixed $port[, mixed $timeout = 0 ][, mixed $username = '' ][, mixed $password = '' ][, mixed $authType = 1 ][, mixed $cert = '' ][, mixed $certPass = '' ][, mixed $caCert = '' ][, mixed $caCertDir = '' ][, mixed $proxyHost = '' ][, mixed $proxyPort = 0 ][, mixed $proxyUsername = '' ][, mixed $proxyPassword = '' ][, mixed $proxyAuthType = 1 ][, mixed $method = 'https' ][, mixed $keepAlive = false ][, mixed $key = '' ][, mixed $keyPass = '' ][, mixed $sslVersion = 0 ]) : false|CurlHandle|resource
Parameters
- $req : mixed
- $server : mixed
- $port : mixed
- $timeout : mixed = 0
- $username : mixed = ''
- $password : mixed = ''
- $authType : mixed = 1
- $cert : mixed = ''
- $certPass : mixed = ''
- $caCert : mixed = ''
- $caCertDir : mixed = ''
- $proxyHost : mixed = ''
- $proxyPort : mixed = 0
- $proxyUsername : mixed = ''
- $proxyPassword : mixed = ''
- $proxyAuthType : mixed = 1
- $method : mixed = 'https'
- $keepAlive : mixed = false
- $key : mixed = ''
- $keyPass : mixed = ''
- $sslVersion : mixed = 0
Return values
false|CurlHandle|resourcesendPayloadCURL()
protected
sendPayloadCURL(Request $req, string $server, int $port[, int $timeout = 0 ][, string $username = '' ][, string $password = '' ][, int $authType = 1 ][, string $cert = '' ][, string $certPass = '' ][, string $caCert = '' ][, string $caCertDir = '' ][, string $proxyHost = '' ][, int $proxyPort = 0 ][, string $proxyUsername = '' ][, string $proxyPassword = '' ][, int $proxyAuthType = 1 ][, string $method = 'https' ][, bool $keepAlive = false ][, string $key = '' ][, string $keyPass = '' ][, int $sslVersion = 0 ]) : Response
Parameters
- $req : Request
- $server : string
- $port : int
- $timeout : int = 0
- $username : string = ''
- $password : string = ''
- $authType : int = 1
- $cert : string = ''
- $certPass : string = ''
- $caCert : string = ''
- $caCertDir : string = ''
- $proxyHost : string = ''
- $proxyPort : int = 0
- $proxyUsername : string = ''
- $proxyPassword : string = ''
- $proxyAuthType : int = 1
- $method : string = 'https'
-
'http' (let curl decide), 'http10', 'http11', 'https', 'h2c' or 'h2'
- $keepAlive : bool = false
- $key : string = ''
- $keyPass : string = ''
- $sslVersion : int = 0
Return values
ResponsesendPayloadHTTP10()
protected
sendPayloadHTTP10(Request $req, string $server, int $port[, int $timeout = 0 ][, string $username = '' ][, string $password = '' ][, int $authType = 1 ][, string $proxyHost = '' ][, int $proxyPort = 0 ][, string $proxyUsername = '' ][, string $proxyPassword = '' ][, int $proxyAuthType = 1 ][, string $method = 'http' ]) : Response
Parameters
- $req : Request
- $server : string
- $port : int
- $timeout : int = 0
- $username : string = ''
- $password : string = ''
- $authType : int = 1
- $proxyHost : string = ''
- $proxyPort : int = 0
- $proxyUsername : string = ''
- $proxyPassword : string = ''
- $proxyAuthType : int = 1
- $method : string = 'http'
Return values
ResponsesendPayloadHTTPS()
protected
sendPayloadHTTPS(Request $req, string $server, int $port[, int $timeout = 0 ][, string $username = '' ][, string $password = '' ][, int $authType = 1 ][, string $cert = '' ][, string $certPass = '' ][, string $caCert = '' ][, string $caCertDir = '' ][, string $proxyHost = '' ][, int $proxyPort = 0 ][, string $proxyUsername = '' ][, string $proxyPassword = '' ][, int $proxyAuthType = 1 ][, bool $keepAlive = false ][, string $key = '' ][, string $keyPass = '' ][, int $sslVersion = 0 ]) : Response
Parameters
- $req : Request
- $server : string
- $port : int
- $timeout : int = 0
- $username : string = ''
- $password : string = ''
- $authType : int = 1
- $cert : string = ''
- $certPass : string = ''
- $caCert : string = ''
- $caCertDir : string = ''
- $proxyHost : string = ''
- $proxyPort : int = 0
- $proxyUsername : string = ''
- $proxyPassword : string = ''
- $proxyAuthType : int = 1
- $keepAlive : bool = false
- $key : string = ''
- $keyPass : string = ''
- $sslVersion : int = 0
Return values
ResponsesendPayloadSocket()
protected
sendPayloadSocket(Request $req, string $server, int $port[, int $timeout = 0 ][, string $username = '' ][, string $password = '' ][, int $authType = 1 ][, string $cert = '' ][, string $certPass = '' ][, string $caCert = '' ][, string $caCertDir = '' ][, string $proxyHost = '' ][, int $proxyPort = 0 ][, string $proxyUsername = '' ][, string $proxyPassword = '' ][, int $proxyAuthType = 1 ][, string $method = 'http' ][, string $key = '' ][, string $keyPass = '' ][, int $sslVersion = 0 ]) : Response
Parameters
- $req : Request
- $server : string
- $port : int
- $timeout : int = 0
- $username : string = ''
- $password : string = ''
- $authType : int = 1
-
only value supported is 1
- $cert : string = ''
- $certPass : string = ''
- $caCert : string = ''
- $caCertDir : string = ''
- $proxyHost : string = ''
- $proxyPort : int = 0
- $proxyUsername : string = ''
- $proxyPassword : string = ''
- $proxyAuthType : int = 1
-
only value supported is 1
- $method : string = 'http'
-
'http' (synonym for 'http10'), 'http10' or 'https'
- $key : string = ''
- $keyPass : string = ''
-
@todo not implemented yet.
- $sslVersion : int = 0
-
@todo not implemented yet. See http://php.net/manual/en/migration56.openssl.php
Return values
ResponsesendViaCURL()
Contributed by Justin Miller Requires curl to be built into PHP NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers!
protected
sendViaCURL(Request $req, string $method, string $server, int $port, string $path, array<string|int, mixed> $opts) : Response
Parameters
- $req : Request
- $method : string
- $server : string
- $port : int
- $path : string
- $opts : array<string|int, mixed>
-
the keys/values match self::getOptions
Tags
Return values
ResponsesendViaSocket()
protected
sendViaSocket(Request $req, string $method, string $server, int $port, string $path, array<string|int, mixed> $opts) : Response
Parameters
- $req : Request
- $method : string
- $server : string
- $port : int
- $path : string
- $opts : array<string|int, mixed>
Return values
Response_try_multicall()
Attempt to boxcar $reqs via system.multicall.
private
_try_multicall(array<string|int, Request> $reqs, int $timeout, string $method) : array<string|int, Response>|Response
Parameters
- $reqs : array<string|int, Request>
- $timeout : int
- $method : string
Return values
array<string|int, Response>|Response —a single Response when the call returned a fault / does not conform to what we expect from a multicall response