Wednesday, 21 August 2013

Reading json input in php

Reading json input in php

'php://input' is working properly in localhost. But in server it returns
empty. Input( request ) to my site is a json, so $_POST didn't work. is
there is any solution for it?
class Webservice_Controller extends CI_Controller {
public $json_input_data;
public function __construct(){
parent::__construct();
$this->json_input_data =
json_decode(file_get_contents('php://input'),TRUE);
}
public function cus_input($label){
if(isset($this->json_input_data[$label])) return
$this->json_input_data[$label];
else return NULL;
}
}

No comments:

Post a Comment