minor changes to the election show page, still having trouble figuring out how to...
[selectricity-live] / public / selectricity-xmlrpc.html
1 <html>
2    <link rel="stylesheet" type="text/css" href="stylesheets/main.css" />
3    <div id="top">
4   <h3>Selectricity XML-RPC<br />
5     <font size="-1">Voting Machinery <em>By the Machinery, for the Machinery</em></font></h3>
6 </div>
7
8
9 <p>Selectricity has a fully functional XML-RPC interface so that you can
10 interface your own application with Selectricity. This API is documented in
11 the doc/ subdirectry, under the class <b>SelectricityService</b>. </p>
12
13 <h2>Usage</h2>
14
15 <p>The XML-RPC service runs at <em>/selectricity_service/vote</em> of the server.
16 All of the available methods are documented both below and in the RubyDoc
17 generated documentation. <br> </p>
18
19 <div class="warning">
20 <h4>Important Note</h4> <p>Please note that the Rails framework automatically
21 changes the case of a method name by capitalizing words separated by an
22 underscore. For example, if you see <em>this_method_name</em>, the actual method
23 name you need to call is actually <em>ThisMethodName</em>. </p>
24 </div>
25
26 <div class="example">
27 <h4>Example PHP Script</h4>
28 <p>Here is a short PHP script that calls the Selectricity Service to output all
29 active QuickVotes to a table. It assumes that you have the samples/utils folder
30 from <a href=http://xmlrpc-epi.sourceforge.net/main.php?t=php_about>The PHP
31   XML-RPC Library</a> installed to utils/ in the include path.
32
33 </p>
34 <blockquote>
35 <pre>
36 &lt;?
37 include("utils/utils.php");
38
39 $host="192.168.195.1";
40 $uri="/selectricity_service/vote";
41 $result = xu_rpc_http_concise(
42   array(
43     'method' =&gt; "ListQuickvotes",
44     'host'  =&gt; $host,
45     'uri'  =&gt; $uri,
46     'port'  =&gt; 3000
47   )
48 );
49 echo "&lt;table border=1&gt;\n";echo "&lt;tr&gt;&lt;th&gt;Name&lt;/th&gt;
50 &lt;th&gt;Description&lt;/th&gt;&lt;th&gt;ID&lt;/th&gt;
51 &lt;th&gt;Candidates&lt;/th&gt;&lt;/tr&gt;\n";
52 foreach($result as $i)
53
54   
55   echo "&lt;tr&gt;&lt;td&gt;";
56   echo $i['name'];
57   echo "&lt;/td&gt;&lt;td&gt;";
58   echo $i['description'];
59   echo "&lt;/td&gt;&lt;td&gt;";
60   echo $i['id'];
61   echo "&lt;/td&gt;&lt;td&gt;";
62   foreach($i['candidate_names'] as $cand)
63   { 
64     echo $cand . ", ";
65   }
66   echo "&lt;/td&gt;&lt;/tr&gt;";
67 }
68 echo "&lt;/table&gt;"
69
70
71 ?&gt;
72 </pre>
73 </blockquote>
74 </div>
75
76 <hr />
77 <p><font size="-1">Copyleft 2006 ::
78 <a href="http://www.media.mit.edu">MIT Media Lab</a> and
79 <a href="http://mako.cc">Benjamin Mako Hill</a></font></p>
80 </html>

Benjamin Mako Hill || Want to submit a patch?