2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00
Files
CATI_Tool/include/limesurvey/admin/classes/xmlrpc/doc/ch12s09.html
azammitdcarf bfe3f2470f Added a backport of Limesurvey CI Remote Control 2 functionality for adding a response.
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)
2011-11-11 05:26:58 +00:00

14 lines
5.9 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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>Does the library support using cookies / http sessions?</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="ch12.html" title="Chapter 12. Frequently Asked Questions" /><link rel="prev" href="ch12s08.html" title="Can I use the ms windows character set?" /><link rel="next" href="apa.html" title="Appendix A. Integration with the PHP xmlrpc extension" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Does the library support using cookies / http sessions?</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch12s08.html">Prev</a> </td><th width="60%" align="center">Chapter 12. Frequently Asked Questions</th><td width="20%" align="right"> <a accesskey="n" href="apa.html">Next</a></td></tr></table><hr /></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="id539485"></a>Does the library support using cookies / http sessions?</h2></div></div></div><p>In short: yes, but a little coding is needed to make it
happen.</p><p>The code below uses sessions to e.g. let the client store a value
on the server and retrieve it later.</p><pre class="programlisting"><code><span style="color: #000000">
<span style="color: #0000BB">$resp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$client</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">send</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">xmlrpcmsg</span><span style="color: #007700">(</span><span style="color: #DD0000">'registervalue'</span><span style="color: #007700">,&nbsp;array(new&nbsp;</span><span style="color: #0000BB">xmlrpcval</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">),&nbsp;new&nbsp;</span><span style="color: #0000BB">xmlrpcval</span><span style="color: #007700">(</span><span style="color: #DD0000">'bar'</span><span style="color: #007700">))));<br />if&nbsp;(!</span><span style="color: #0000BB">$resp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">faultCode</span><span style="color: #007700">())<br />{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$cookies&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$resp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">cookies</span><span style="color: #007700">();<br />&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">array_key_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'PHPSESSID'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$cookies</span><span style="color: #007700">))&nbsp;</span><span style="color: #FF8000">//&nbsp;nb:&nbsp;make&nbsp;sure&nbsp;to&nbsp;use&nbsp;the&nbsp;correct&nbsp;session&nbsp;cookie&nbsp;name<br />&nbsp;&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$session_id&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$cookies</span><span style="color: #007700">[</span><span style="color: #DD0000">'PHPSESSID'</span><span style="color: #007700">][</span><span style="color: #DD0000">'value'</span><span style="color: #007700">];<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;do&nbsp;some&nbsp;other&nbsp;stuff&nbsp;here...<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$client</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">'PHPSESSID'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$session_id</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$client</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">send</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">xmlrpcmsg</span><span style="color: #007700">(</span><span style="color: #DD0000">'getvalue'</span><span style="color: #007700">,&nbsp;array(new&nbsp;</span><span style="color: #0000BB">xmlrpcval</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">)));<br />&nbsp;&nbsp;}<br />}</span>
</span>
</code></pre><p>Server-side sessions are handled normally like in any other
php application. Please see the php manual for more information about
sessions.</p><p>NB: unlike web browsers, not all xmlrpc clients support usage of
http cookies. If you have troubles with sessions and control only the
server side of the communication, please check with the makers of the
xmlrpc client in use.</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch12s08.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch12.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apa.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Can I use the ms windows character set? </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix A. Integration with the PHP xmlrpc extension</td></tr></table></div></body></html>