title: Create a RESTful API in PHP?
body: <p>I developed a very quick and simple PHP application for reading classified ads from an XML file and allowing the user to perform CRUD operations on it (this was a homework assignment).</p>
  
  <p>I'm now tasked with developing this application to a RESTful service.  The professor actually doesn't seem to have any experience with RESTful services, because he said my application was find to hand in for the next assignment, when my research indicates it doesn't really fulfil all the RESTful requirements.</p>
  
  <p>Regardless, I want to do this correctly for learning purposes, even if I can hand in my old assignment and get a good grade.  I'm having trouble learning where to begin though; I'm not sure exactly what a RESTful service really is.</p>
  
  <p>I think the best way to get advice is to post sample code from my previous assignment to see how I handled things and how I need to handle things instead.</p>
  
  <p>For instance, here is how I create new classifieds.</p>
  
  <p><strong>Create.php</strong></p>
  
  <pre><code>//Basically just a list of &lt;INPUT TYPE = "text" NAME = "something"&gt; in the &lt;body&gt; fields
  </code></pre>
  
  <p><strong>CreateSuccess.php</strong></p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;&lt;?php $simplerXML = simplexml_load_file('file.xml'); 
  //Generate the basic ad information
  $newAd = $simplerXML-&gt;addChild('advertisement','');
  $newAd-&gt;addAttribute('category', $_POST["category"]);
  $title = $newAd-&gt;addChild('title', $_POST["title"]);
  $title-&gt;addAttribute('ID', $_POST["ID"]);
  $pageTitle = $newAd-&gt;addChild('pagetitle', $_POST["pagetitle"]);
  //etc, for all the SUBMIT boxes
  
  //save the XML
  $simplerXML-&gt;asXML('file.xml');
  echo "&lt;script type='text/javascript'&gt;
  //redirect back to ad listing page
  window.onload = function () { top.location.href = 'ads.php'; };
  &lt;/script&gt;";
  ?&gt;&lt;/head&gt;
  &lt;body&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>I'm also using URL parameters for the RUD actions.  I've heard URL parameters are not allowed as well?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT:
  So the SWITCH statement, does it go in the index.php file?  And then each case will call a function, ie CreateXML for the POST method?
  Then the parameters it needs will be the object type, object id, and content type?  How do I get the values to update the XML with, do I just send it to the Create.php file containing the list of input boxes?</p>