title: Reading json input in php
body: <p><code>php://input</code> is working properly in localhost. But in server it returns empty.
  Input( request ) to my site is a <code>json</code>(<em>REST - application/json type</em>), so <code>$_POST</code> didn't work ( please read <a href="https://stackoverflow.com/questions/8893574/php-php-input-vs-post">This question</a> ) .</p>
  <blockquote>
  <p>$_POST works with key-value pair type inputs like form-data or x-www-urlencoded</p>
  <p><strong>key1=value1&amp;key2=value2&amp;key3=value3</strong></p>
  </blockquote>
  <p>I'm using <code>application/json</code> as input (in <strong>REST</strong>).</p>
  <blockquote>
  <p>Like {'key1':'value1','key2':'value2','key3':'value3'}</p>
  </blockquote>
  <p>This can't be handled using <code>$_POST</code>. But using <code>php://input</code> can help to read that data.</p>
  <p>My code</p>
  <pre><code>class Webservice_Controller extends CI_Controller {
      public $json_input_data;
      public function __construct(){
          parent::__construct();
          $this-&gt;json_input_data = json_decode(file_get_contents('php://input'),TRUE);
      }
      public function json_input($label){
          if(isset($this-&gt;json_input_data[$label])) return $this-&gt;json_input_data[$label];
          else return NULL;
      }
  }
  </code></pre>
  <p><em>Above code is works fine in another webserver also, But not in the current one. :(</em></p>
  <p>I think my web server deny access to <code>php://input</code>.</p>
  <blockquote>
  <p><strong>Is there is any other methods to read json input in php ?</strong></p>
  </blockquote>