storing contents of php://input in a variable storing contents of php://input in a variable codeigniter codeigniter

storing contents of php://input in a variable


Thanks for all the help, it turns out that in order to work, the content type of the request must be application/xml, not application/x-www-form-urlencoded as it was.


if $this->request->format evaluates to false or NULL or 0, the later part of and operator does not execute.

  $this->request->format and $this->request->body = file_get_contents('php://input');                             ^                             |                             +--- this part wont execute

You should have written it like

if($this->request->format){    $this->request->body = file_get_contents('php://input');}

This helps in debugging.