title: PHP decode JSON POST
body: <p>I"m trying to receive <code>POST</code> data in the form of JSON. I'm curling it as: </p>
  
  <pre><code>curl -v --header 'content-type:application/json' -X POST --data '{"content":"test content","friends":[\"38383\",\"38282\",\"38389\"],"newFriends":0,"expires":"5-20-2013","region":"35-28"}' http://testserver.com/wg/create.php?action=post
  </code></pre>
  
  <p>On the PHP side my code is: </p>
  
  <pre><code>$data = json_decode(file_get_contents('php://input'));
  
      $content    = $data-&gt;{'content'};
      $friends    = $data-&gt;{'friends'};       // JSON array of FB IDs
      $newFriends = $data-&gt;{'newFriends'};
      $expires    = $data-&gt;{'expires'};
      $region     = $data-&gt;{'region'};    
  </code></pre>
  
  <p>But even when I <code>print_r ( $data)</code> nothing gets returned to me. Is this the right way of processing a <code>POST</code> without a form?</p>