I have created a simple Rest webservice with Codeigniter. When i send post data with Curl from another application and display $_POST is empty.
Simple PHP client:
$url = 'http://localhost/ci-access/api_v1/register_events';
$data = array(
'name' => 'tester'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
$output = curl_exec($ch);
curl_close($ch);
Codeigniter webservice:
public function register_events() {
die(var_dump($_POST));
}
Is there an option to set in Codeigniter ? How can i read posted data ?
try pass php curl_setopt($ch, CURLOPT_POST, true);
option first or remove it.