git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_SGD/tags/3.7.0.2_original@1 eb19766c-00d9-a042-a3a0-45cb8ec72764
17 lines
32 KiB
HTML
17 lines
32 KiB
HTML
<html><head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>3. xmlrpc_client</title><link rel="stylesheet" href="html.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.71.1"><link rel="start" href="index.html" title="XML-RPC for PHP"><link rel="up" href="ch07.html" title="Chapter 7. Class documentation"><link rel="prev" href="ch07s02.html" title="2. xmlrpcmsg"><link rel="next" href="ch07s04.html" title="4. xmlrpcresp"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3. xmlrpc_client</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch07s02.html">Prev</a> </td><th width="60%" align="center">Chapter 7. Class documentation</th><td width="20%" align="right"> <a accesskey="n" href="ch07s04.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="xmlrpc-client"></a>3. xmlrpc_client</h2></div></div></div><p>This is the basic class used to represent a client of an XML-RPC server.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e1572"></a>3.1. Creation</h3></div></div></div><p>The constructor accepts one of two possible syntaxes:</p><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client = new <b class="fsfunc">xmlrpc_client</b>(</code></td><td><var class="pdparam">$server_url</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code>string</code> </td><td><code><var class="pdparam">$server_url</var>;</code></td></tr></table><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client = new <b class="fsfunc">xmlrpc_client</b>(</code></td><td><var class="pdparam">$server_path</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$server_hostname</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$server_port</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$transport</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>string</code> </td><td><code><var class="pdparam">$server_path</var>;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$server_hostname</var>;</code></td></tr><tr><td><code>int</code> </td><td><code><var class="pdparam">$server_port</var>80;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$transport</var>'http';</code></td></tr></table></div><p>Here are a couple of usage examples of the first form:</p><pre class="programlisting">
|
|
$client = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php);
|
|
$another_client = new xmlrpc_client("https://james:bond@secret.service.com:4443/xmlrpcserver?agent=007");
|
|
|
|
</pre><p>The second syntax does not allow to express a username and password to be used for basic HTTP authorization as in the second example above, but instead it allows to choose whether xmlrpc calls will be made using the HTTP 1.0 or 1.1 protocol.</p><p>Here's another example client set up to query Userland's XML-RPC server at <span class="emphasis"><em>betty.userland.com</em></span>:</p><pre class="programlisting">
|
|
$client = new xmlrpc_client("/RPC2", "betty.userland.com", 80);
|
|
|
|
</pre><p>The <em class="parameter"><code>server_port</code></em> parameter is optional, and if omitted will default to 80 when using HTTP and 443 when using HTTPS (see the <a href="ch07s03.html#xmlrpc-client-send">xmlrpc_client->send</a> method below).</p><p>The <em class="parameter"><code>transport</code></em> parameter is optional, and if omitted will default to 'http'. Allowed values are either '<span class="symbol">http'</span>, '<span class="symbol">https</span>' or '<span class="symbol">http11'</span>. Its value can be overridden with every call to the <code class="methodname">send</code> method. See the <code class="methodname">send</code> method below for more details about the meaning of the different values.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e1657"></a>3.2. Methods</h3></div></div></div><p>This class supports the following methods.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="xmlrpc-client-send"></a>3.2.1. send</h4></div></div></div><p>This method takes the forms:</p><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$response = $client-><b class="fsfunc">send</b>(</code></td><td><var class="pdparam">$xmlrpc_message</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$timeout</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$transport</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code>xmlrpc_msg</code> </td><td><code><var class="pdparam">$xmlrpc_message</var>;</code></td></tr><tr><td><code>int</code> </td><td><code><var class="pdparam">$timeout</var>;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$transport</var>;</code></td></tr></table><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$responses = $client-><b class="fsfunc">send</b>(</code></td><td><var class="pdparam">$xmlrpc_messages</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$timeout</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$transport</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code>array</code> </td><td><code><var class="pdparam">$xmlrpc_messages</var>;</code></td></tr><tr><td><code>int</code> </td><td><code><var class="pdparam">$timeout</var>;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$transport</var>;</code></td></tr></table><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$response = $client-><b class="fsfunc">send</b>(</code></td><td><var class="pdparam">$xml_payload</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$timeout</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$transport</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>string</code> </td><td><code><var class="pdparam">$xml_payload</var>;</code></td></tr><tr><td><code>int</code> </td><td><code><var class="pdparam">$timeout</var>;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$transport</var>;</code></td></tr></table></div><p>Where <em class="parameter"><code>xmlrpc_message</code></em> is an instance of <code class="classname">xmlrpcmsg</code> (see <a href="ch07s02.html">xmlrpcmsg</a>), and <em class="parameter"><code>response</code></em> is an instance of <code class="classname">xmlrpcresp</code> (see <a href="ch07s04.html">xmlrpcresp</a>).</p><p><em class="parameter"><code>If xmlrpc_messages</code></em> is an array of message instances, <code class="code">responses</code> will be an array of response instances. The client will try to make use of a single <code class="code">system.multicall</code> xml-rpc method call to forward to the server all the messages in a single HTTP round trip, unless <code class="code">$client->no_multicall</code> has been previously set to <code class="code">TRUE</code> (see the multicall method below), in which case many consecutive xmlrpc requests will be sent.</p><p>The third syntax allows to build by hand (or any other means) a complete xmlrpc request message, and send it to the server. <em class="parameter"><code>xml_payload</code></em> 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 xmlrpc functions (see <a href="http://www.php.net/xmlrpc" target="_top">the php manual on xmlrpc</a>).</p><p>The <em class="parameter"><code>timeout</code></em> is optional, and will be set to <code class="literal">0</code> (wait for platform-specific predefined timeout) if omitted. This timeout value is passed to <code class="function">fsockopen()</code>. It is also used for detecting server timeouts during communication (i.e. if the server does not send anything to the client for <em class="parameter"><code>timeout</code></em> seconds, the connection will be closed).</p><p>The <em class="parameter"><code>transport</code></em> parameter is optional, and if omitted will default to the transport set using instance creator or 'http' if omitted. The only other valid values are 'https', which will use an SSL HTTP connection to connect to the remote server, and 'http11'. Note that your PHP must have the "curl" extension compiled in order to use both these features. Note that when using SSL you should normally set your port number to 443, unless the SSL server you are contacting runs at any other port.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>PHP 4.0.6 has a bug which prevents SSL working.</p></div><p>In addition to low-level errors, the XML-RPC server you were querying may return an error in the <code class="classname">xmlrpcresp</code> object. See <a href="ch07s04.html">xmlrpcresp</a> for details of how to handle these errors.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="multicall"></a>3.2.2. multicall</h4></div></div></div><p>This method takes the form:</p><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$responses = $client->multicall(</code></td><td><var class="pdparam">$messages</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$timeout</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$transport</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$fallback</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>array</code> </td><td><code><var class="pdparam">$messages</var>;</code></td></tr><tr><td><code>int</code> </td><td><code><var class="pdparam">$timeout</var>;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$transport</var>;</code></td></tr><tr><td><code>bool</code> </td><td><code><var class="pdparam">$fallback</var>;</code></td></tr></table></div><p>This method is used to boxcar many method calls in a single xml-rpc request. It will try first to make use of the <code class="code">system.multicall</code> xml-rpc method call, and fall back to executing many separate requests if the server returns any error.</p><p><em class="parameter"><code>msgs</code></em> is an array of <code class="classname">xmlrpcmsg</code> objects (see <a href="ch07s02.html">xmlrpcmsg</a>), and <em class="parameter"><code>response</code></em> is an array of <code class="classname">xmlrpcresp</code> objects (see <a href="ch07s04.html">xmlrpcresp</a>).</p><p>The <em class="parameter"><code>timeout</code></em> and <em class="parameter"><code>transport</code></em> parameters are optional, and behave as in the <code class="methodname">send</code> method above.</p><p>The <em class="parameter"><code>fallback</code></em> parameter is optional, and defaults to <code class="constant">TRUE</code>. When set to <code class="constant">FALSE</code> it will prevent the client to try using many single method calls in case of failure of the first multicall request. It should be set only when the server is known to support the multicall extension.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1872"></a>3.2.3. setAcceptedCompression</h4></div></div></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client->setAcceptedCompression(</code></td><td><var class="pdparam">$compressionmethod</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>string</code> </td><td><code><var class="pdparam">$compressionmethod</var>;</code></td></tr></table></div><p>This method defines whether the client will accept compressed xml payload forming the bodies of the xmlrpc responses received from servers. Note that enabling reception of compressed responses merely adds some standard http headers to xmlrpc requests. It is up to the xmlrpc server to return compressed responses when receiving such requests. Allowed values for <em class="parameter"><code>compressionmethod</code></em> are: 'gzip', 'deflate', 'any' or null (with any meaning either gzip or deflate).</p><p>This requires the "zlib" extension to be enabled in your php install. If it is, by default <code class="classname">xmlrpc_client</code> instances will enable reception of compressed content.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1894"></a>3.2.4. setCaCertificate</h4></div></div></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client->setCaCertificate(</code></td><td><var class="pdparam">$certificate</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$is_dir</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>string</code> </td><td><code><var class="pdparam">$certificate</var>;</code></td></tr><tr><td><code>bool</code> </td><td><code><var class="pdparam">$is_dir</var>;</code></td></tr></table></div><p>This method sets an optional certificate to be used in SSL-enabled communication to validate a remote server with (when the <em class="parameter"><code>server_method</code></em> is set to 'https' in the client's construction or in the send method and <code class="methodname">SetSSLVerifypeer</code> has been set to <code class="constant">TRUE</code>).</p><p>The <em class="parameter"><code>certificate</code></em> parameter must be the filename of a PEM formatted certificate, or a directory containing multiple certificate files. The <em class="parameter"><code>is_dir</code></em> parameter defaults to <code class="constant">FALSE</code>, set it to <code class="constant">TRUE</code> to specify that <em class="parameter"><code>certificate</code></em> indicates a directory instead of a single file.</p><p>This requires the "curl" extension to be compiled into your installation of PHP. For more details see the man page for the <code class="function">curl_setopt</code> function.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1944"></a>3.2.5. setCertificate</h4></div></div></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client->setCertificate(</code></td><td><var class="pdparam">$certificate</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$passphrase</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>string</code> </td><td><code><var class="pdparam">$certificate</var>;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$passphrase</var>;</code></td></tr></table></div><p>This method sets the optional certificate and passphrase used in SSL-enabled communication with a remote server (when the <em class="parameter"><code>server_method</code></em> is set to 'https' in the client's construction or in the send method).</p><p>The <em class="parameter"><code>certificate</code></em> parameter must be the filename of a PEM formatted certificate. The <em class="parameter"><code>passphrase</code></em> parameter must contain the password required to use the certificate.</p><p>This requires the "curl" extension to be compiled into your installation of PHP. For more details see the man page for the <code class="function">curl_setopt</code> function.</p><p>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.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1981"></a>3.2.6. setCookie</h4></div></div></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client->setCookie(</code></td><td><var class="pdparam">$name</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$value</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$path</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$domain</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$port</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>string</code> </td><td><code><var class="pdparam">$name</var>;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$value</var>;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$path</var>;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$domain</var>;</code></td></tr><tr><td><code>int</code> </td><td><code><var class="pdparam">$port</var>;</code></td></tr></table></div><p>This method sets a cookie that will be sent to the xmlrpc server along with every further request (useful e.g. for keeping session info outside of the xml-rpc payload).</p><p><em class="parameter"><code>$value</code></em> is optional, and defaults to null.</p><p><em class="parameter"><code>$path, $domain and $port</code></em> are optional, and will be omitted from the cookie header if unspecified. Note that setting any of these values will turn the cookie into a 'version 1' cookie, that might not be fully supported by the server (see RFC2965 for more details).</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e2023"></a>3.2.7. setCredentials</h4></div></div></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client->setCredentials(</code></td><td><var class="pdparam">$username</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$password</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$authtype</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>string</code> </td><td><code><var class="pdparam">$username</var>;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$password</var>;</code></td></tr><tr><td><code>int</code> </td><td><code><var class="pdparam">$authtype</var>;</code></td></tr></table></div><p>This method sets the username and password for authorizing the client to a server. 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 <code class="constant">CURLAUTH_DIGEST</code> and <code class="constant">CURLAUTH_NTLM</code> as values for the authtype parameter.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e2053"></a>3.2.8. setDebug</h4></div></div></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client->setDebug(</code></td><td><var class="pdparam">int$debugLvl</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code></code> </td><td><code><var class="pdparam">int$debugLvl</var>;</code></td></tr></table></div><p><em class="parameter"><code>debugLvl</code></em> is either <code class="literal">0, 1</code> or 2 depending on whether you require the client to print debugging information to the browser. The default is not to output this information (0).</p><p>The debugging information at level 1includes 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 level2, the complete payload of the xmlrpc request is also printed, before being sent t the server.</p><p>This option can be very useful when debugging servers as it allows you to see exactly what the client sends and the server returns.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e2076"></a>3.2.9. setKey</h4></div></div></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client->setKey(</code></td><td><var class="pdparam">$key</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$keypass</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>int</code> </td><td><code><var class="pdparam">$key</var>;</code></td></tr><tr><td><code>int</code> </td><td><code><var class="pdparam">$keypass</var>;</code></td></tr></table></div><p>This method sets the optional certificate key and passphrase used in SSL-enabled communication with a remote server (when the <em class="parameter"><code>transport</code></em> is set to 'https' in the client's construction or in the send method).</p><p>This requires the "curl" extension to be compiled into your installation of PHP. For more details see the man page for the <code class="function">curl_setopt</code> function.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e2103"></a>3.2.10. setProxy</h4></div></div></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client->setProxy(</code></td><td><var class="pdparam">$proxyhost</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$proxyport</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$proxyusername</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$proxypassword</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">$authtype</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>string</code> </td><td><code><var class="pdparam">$proxyhost</var>;</code></td></tr><tr><td><code>int</code> </td><td><code><var class="pdparam">$proxyport</var>;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$proxyusername</var>;</code></td></tr><tr><td><code>string</code> </td><td><code><var class="pdparam">$proxypassword</var>;</code></td></tr><tr><td><code>int</code> </td><td><code><var class="pdparam">$authtype</var>;</code></td></tr></table></div><p>This method enables calling servers via an HTTP proxy. The <em class="parameter"><code>proxyusername</code></em>,<em class="parameter"><code> proxypassword</code></em> and <em class="parameter"><code>authtype</code></em> parameters are optional. <em class="parameter"><code>Authtype</code></em> defaults to <code class="constant">CURLAUTH_BASIC</code> (Basic authentication protocol); the only other valid value is the constant <code class="constant">CURLAUTH_NTLM</code>, and has effect only when the client uses the HTTP 1.1 protocol.</p><p>NB: CURL versions before 7.11.10 cannot use a proxy to communicate with https servers.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e2157"></a>3.2.11. setRequestCompression</h4></div></div></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client->setRequestCompression(</code></td><td><var class="pdparam">$compressionmethod</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>string</code> </td><td><code><var class="pdparam">$compressionmethod</var>;</code></td></tr></table></div><p>This method defines whether the xml payload forming the request body will be sent to the server in compressed format, as per the HTTP specification. This is particularly useful for large request parameters and over slow network connections. Allowed values for <em class="parameter"><code>compressionmethod</code></em> are: 'gzip', 'deflate', 'any' or null (with any meaning either gzip or deflate). Note that there is no automatic fallback mechanism in place for errors due to servers not supporting receiving compressed request bodies, so make sure that the particular server you are querying does accept compressed requests before turning it on.</p><p>This requires the "zlib" extension to be enabled in your php install.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e2176"></a>3.2.12. setSSLVerifyHost</h4></div></div></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client->setSSLVerifyHost(</code></td><td><var class="pdparam">$i</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>int</code> </td><td><code><var class="pdparam">$i</var>;</code></td></tr></table></div><p>This method defines whether connections made to XML-RPC backends via HTTPS should verify the remote host's SSL certificate's common name (CN). By default, only the existence of a CN is checked. <em class="parameter"><code><em class="parameter"><code>$i</code></em></code></em> should be an integer value; 0 to not check the CN at all, 1 to merely check for its existence, and 2 to check that the CN on the certificate matches the hostname that is being connected to.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e2194"></a>3.2.13. setSSLVerifyPeer</h4></div></div></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">$client->setSSLVerifyPeer(</code></td><td><var class="pdparam">$i</var><code>)</code>;</td><td> </td></tr></table><table border="0" summary="Function argument synopsis" cellspacing="0" cellpadding="0"><tr><td><code>bool</code> </td><td><code><var class="pdparam">$i</var>;</code></td></tr></table></div><p>This method defines whether connections made to XML-RPC backends via HTTPS should verify the remote host's SSL certificate, and cause the connection to fail if the cert verification fails. <em class="parameter"><code><em class="parameter"><code>$i</code></em></code></em> should be a boolean value. Default value: <code class="constant">TRUE</code>. To specify custom SSL certificates to validate the server with, use the <code class="methodname">setCaCertificate</code> method.</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="d0e2218"></a>3.3. Variables</h3></div></div></div><p>NB: direct manipulation of these variables is only recommended for advanced users.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e2223"></a>3.3.1. no_multicall</h4></div></div></div><p>This member variable determines whether the multicall() method will try to take advantage of the system.multicall xmlrpc 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.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="d0e2228"></a>3.3.2. request_charset_encoding</h4></div></div></div><p>This is the charset encoding that will be used for serializing request sent by the client.</p><p>If defaults to NULL, which means using US-ASCII and encoding all characters outside of the ASCII 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).</p><p>Valid values are 'US-ASCII', 'UTF-8' and 'ISO-8859-1'</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="return-type"></a>3.3.3. return_type</h4></div></div></div><p>This member variable determines whether the value returned inside an xmlrpcresp object as results of calls to the send() and multicall() methods will be an xmlrpcval 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 xmlrpcresp 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 xmlrpc string or base64 value.</p><p>Example usage:</p><pre class="programlisting">
|
|
$client = new xmlrpc_client("phpxmlrpc.sourceforge.net/server");
|
|
$client->return_type = 'phpvals';
|
|
$message = new xmlrpcmsg("examples.getStateName", array(new xmlrpcval(23, "int")));
|
|
$resp = $client->send($message);
|
|
if ($resp->faultCode()) echo 'KO. Error: '.$resp->faultString(); else echo 'OK: got '.$resp->value();
|
|
|
|
</pre><p>For more details about usage of the 'xml' value, see Appendix A.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch07s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch07.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch07s04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2. xmlrpcmsg </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 4. xmlrpcresp</td></tr></table></div></body></html> |