title: POST request method via a call to GET, SlimPHP, RedBeanPHP
body: <p>Tools I'm using: Slim Framework &amp; RedBeanPHP</p>
  
  <p>I'm studying this article: <a href="http://www.ibm.com/developerworks/library/x-slim-rest/" rel="nofollow">http://www.ibm.com/developerworks/library/x-slim-rest/</a> and especially this method:</p>
  
  <pre><code>// handle POST requests to /articles
  $app-&gt;post('/articles', function () use ($app) 
  {    
  try 
  {   // get and decode JSON request body
          $request = $app-&gt;request();
          $body = $request-&gt;getBody();
          $input = json_decode($body); 
  
          // store article record
          $article = R::dispense('articles');
          $article-&gt;title = (string)$input-&gt;title;
          $article-&gt;url = (string)$input-&gt;url;
          $article-&gt;date = (string)$input-&gt;date;
          $id = R::store($article);    
  
          // return JSON-encoded response body
          $app-&gt;response()-&gt;header('Content-Type', 'application/json');
          echo json_encode(R::exportAll($article));
  
  } catch (Exception $e) {
          $app-&gt;response()-&gt;status(400);
          $app-&gt;response()-&gt;header('X-Status-Reason', $e-&gt;getMessage());
  }
  });
  </code></pre>
  
  <p>I run the application or refresh/enter whatever you like, but don't see any reporting of POST in my console as in the article?</p>
  
  <p>I'm expecting to see: <a href="http://www.ibm.com/developerworks/library/x-slim-rest/#f5" rel="nofollow">http://www.ibm.com/developerworks/library/x-slim-rest/#f5</a></p>
  
  <p>in my console.</p>
  
  <p>Instead I get: <a href="http://acookson.org/?attachment_id=1221" rel="nofollow">http://acookson.org/?attachment_id=1221</a></p>
  
  <p>It's a GET request method right? So how does the author trick the browser into reporting it as a POST request without the use of a HTML form? </p>
  
  <p>With this line I hear you say:</p>
  
  <pre><code>// get and decode JSON request body
  $request = $app-&gt;request();
  $body = $request-&gt;getBody();
  $input = json_decode($body); 
  </code></pre>
  
  <p>Well I'm copying the article like for like and nope - nothing added to the database either.</p>
  
  <p>I can acheive something similar with CURL</p>
  
  <pre><code>$ curl -i -X POST -H 'Content-Type: application/json' -d '{"id": "3", "title": "Programming with C++", "url":"http:\/\/www.google.com\/programming\/C++","date":"2013-01-10"}' http://example.localhost/articles
  HTTP/1.1 200 OK
  Date: Mon, 01 Apr 2013 08:52:50 GMT
  Server: Apache/2.2.22 (Ubuntu)
  X-Powered-By: PHP/5.4.6-1ubuntu1.2
  Content-Length: 116
  Content-Type: application/json
  
  POST
  [{"id":3,"title":"Programming with C++","url":"http:\/\/www.google.com\/programming\/C++","date":"2013-01-10"}]
  </code></pre>
  
  <p>with row 3 added to my database:</p>
  
  <pre><code>mysql&gt; select * from articles\G;
  *************************** 1. row ***************************
  id: 1
  title: Search and integrate Google+ activity streams with PHP applications
  url: http://www.ibm.com/developerworks/xml/library/x-googleplusphp/index.html
  date: 2012-07-10
  *************************** 2. row ***************************
  id: 2
  title: Getting Started with Zend Server CE
  url: http://devzone.zend.com/1389/getting-started-with-zend-server-ce/
  date: 2009-03-02
  *************************** 3. row ***************************
  id: 3
  title: Programming with C++
  url: http://www.google.com/programming/C++
  date: 2013-01-10
  3 rows in set (0.00 sec)
  </code></pre>
  
  <p>what am I missing?</p>