<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>xmlrpc</title>
  <link rel="alternate" type="text/html" href="http://pingv.com/tag/xmlrpc"/>
  <link rel="self" type="application/atom+xml" href="http://pingv.com/taxonomy/term/230/atom/feed"/>
  <id>http://pingv.com/taxonomy/term/230/atom/feed</id>
  <updated>2007-08-21T18:30:31-05:00</updated>
  <entry>
    <title>Quick and dirty XMLRPC Clients for testing</title>
    <link rel="alternate" type="text/html" href="http://pingv.com/blog/john-fiala/200708/quick-and-dirty-xmlrpc-clients-testing" />
    <id>http://pingv.com/blog/john-fiala/200708/quick-and-dirty-xmlrpc-clients-testing</id>
    <published>2007-08-21T19:15:27-05:00</published>
    <updated>2007-08-21T18:30:31-05:00</updated>
    <author>
      <name>John Fiala</name>
    </author>
    <category term="code" />
    <category term="Drupal" />
    <category term="hook_xmlrpc" />
    <category term="testing" />
    <category term="xmlrpc" />
    <content type="html"><![CDATA[<p>Hey folks.  I'm a new hire here at the pingVision ranch, and so I've not had a lot to say, but some of my esteemed colleagues suggested I share this tidbit.</p>
<p>I recently had to create a small, simple xmlrpc service in a Drupal project.  That involves hook_xmlrpc, which is very well documented and is pretty darn easy to use.  However, for testing purposes I needed to throw together a simple page to hit my service and display what it found.  After a little googling, I found this page: <a href="http://keithdevens.com/software/xmlrpc" title="http://keithdevens.com/software/xmlrpc">http://keithdevens.com/software/xmlrpc</a>.</p>
<p>If you download the source he's sharing there, then you can set up a simple xml client like so:</p>
<div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">require_once </span><span style="color: #DD0000">'source.php'</span><span style="color: #007700">;</p>
<p></span><span style="color: #0000BB">define</span><span style="color: #007700">(</span><span style="color: #DD0000">"XMLRPC_DEBUG"</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);</p>
<p></span><span style="color: #0000BB">XMLRPC_request</span><span style="color: #007700">(</span><span style="color: #DD0000">'time.xmlrpc.com'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/RPC2'</span><span style="color: #007700">, </span><span style="color: #DD0000">'currentTime.getCurrentTime'</span><span style="color: #007700">, </span><span style="color: #0000BB">NULL</span><span style="color: #007700">, </span><span style="color: #0000BB">NULL</span><span style="color: #007700">);</p>
<p></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);</p>
<p></span><span style="color: #0000BB">XMLRPC_debug_print</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
<p>This works very well - the first parameter is the host you're going to, the second is the path - for hook_xmlrpc in Drupal it's going to be either '/xmlrpc.php' or the like - the third parameter is the method name, the fourth is an array of parameters for the method, and the last is some sort of user_agent, which I don't currently understand the purpose of.  (Apparently it's the browser you're querying from, or something like that - as far as I can see, leaving it NULL is fine.)</p>
<p>Naturally the print_r($result) gives you the result on the screen, but the XMLRPC_debug_print() function additionally gives you a lot of debugging information for your rpc call - the xml you sent, the xml you received, and another view of the data that XMLRPC_request returned.</p>
<p>I hope that's helpful to folks out there, and I look forward to learning more about Drupal's many interesting features.</p>
    ]]></content>
  </entry>
</feed>
