mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Can be used to insert a new response into a questionnaire via XML-RPC Added xmlrpc package from: http://phpxmlrpc.sourceforge.net (new BSD licence compatible with GPL)
9 lines
6.5 KiB
HTML
9 lines
6.5 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Appendix A. Integration with the PHP xmlrpc extension</title><link rel="stylesheet" href="xmlrpc.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.74.3" /><link rel="home" href="index.html" title="XML-RPC for PHP" /><link rel="up" href="index.html" title="XML-RPC for PHP" /><link rel="prev" href="ch12s09.html" title="Does the library support using cookies / http sessions?" /><link rel="next" href="apb.html" title="Appendix B. Substitution of the PHP xmlrpc extension" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix A. Integration with the PHP xmlrpc extension</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch12s09.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="apb.html">Next</a></td></tr></table><hr /></div><div class="appendix" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="integration"></a>Appendix A. Integration with the PHP xmlrpc extension</h2></div></div></div><p>To be documented more...</p><p>In short: for the fastest execution possible, you can enable the php
|
||
native xmlrpc extension, and use it in conjunction with phpxmlrpc. The
|
||
following code snippet gives an example of such integration</p><pre class="programlisting"><code><span style="color: #000000">
|
||
<span style="color: #0000BB"></span><span style="color: #FF8000">/*** client side ***/<br /></span><span style="color: #0000BB">$c </span><span style="color: #007700">= new </span><span style="color: #0000BB">xmlrpc_client</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://phpxmlrpc.sourceforge.net/server.php'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// tell the client to return raw xml as response value<br /></span><span style="color: #0000BB">$c</span><span style="color: #007700">-></span><span style="color: #0000BB">return_type </span><span style="color: #007700">= </span><span style="color: #DD0000">'xml'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// let the native xmlrpc extension take care of encoding request parameters<br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= </span><span style="color: #0000BB">$c</span><span style="color: #007700">-></span><span style="color: #0000BB">send</span><span style="color: #007700">(</span><span style="color: #0000BB">xmlrpc_encode_request</span><span style="color: #007700">(</span><span style="color: #DD0000">'examples.getStateName'</span><span style="color: #007700">, </span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'stateno'</span><span style="color: #007700">]));<br /><br />if (</span><span style="color: #0000BB">$r</span><span style="color: #007700">-></span><span style="color: #0000BB">faultCode</span><span style="color: #007700">())<br /> </span><span style="color: #FF8000">// HTTP transport error<br /> </span><span style="color: #007700">echo </span><span style="color: #DD0000">'Got error '</span><span style="color: #007700">.</span><span style="color: #0000BB">$r</span><span style="color: #007700">-></span><span style="color: #0000BB">faultCode</span><span style="color: #007700">();<br />else<br />{<br /> </span><span style="color: #FF8000">// HTTP request OK, but XML returned from server not parsed yet<br /> </span><span style="color: #0000BB">$v </span><span style="color: #007700">= </span><span style="color: #0000BB">xmlrpc_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">-></span><span style="color: #0000BB">value</span><span style="color: #007700">());<br /> </span><span style="color: #FF8000">// check if we got a valid xmlrpc response from server<br /> </span><span style="color: #007700">if (</span><span style="color: #0000BB">$v </span><span style="color: #007700">=== </span><span style="color: #0000BB">NULL</span><span style="color: #007700">)<br /> echo </span><span style="color: #DD0000">'Got invalid response'</span><span style="color: #007700">;<br /> else<br /> </span><span style="color: #FF8000">// check if server sent a fault response<br /> </span><span style="color: #007700">if (</span><span style="color: #0000BB">xmlrpc_is_fault</span><span style="color: #007700">(</span><span style="color: #0000BB">$v</span><span style="color: #007700">))<br /> echo </span><span style="color: #DD0000">'Got xmlrpc fault '</span><span style="color: #007700">.</span><span style="color: #0000BB">$v</span><span style="color: #007700">[</span><span style="color: #DD0000">'faultCode'</span><span style="color: #007700">];<br /> else<br /> echo</span><span style="color: #DD0000">'Got response: '</span><span style="color: #007700">.</span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$v</span><span style="color: #007700">);<br />}</span>
|
||
</span>
|
||
</code></pre></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch12s09.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="apb.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Does the library support using cookies / http sessions? </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix B. Substitution of the PHP xmlrpc extension</td></tr></table></div></body></html>
|