Possible duplicate:
How to get POST body in php?
I get a POST that contains JSON, the problem is that I get that $ _POST is empty. To check when I get POST, I create a file that contains $ _POST, $ _GET and $ _REQUEST, and they are all empty.
The client that sends the request does something like this:
$itemJson = '{ "id": 00, "value": "ok" }'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: '. strlen($itemJson)) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $itemJson); curl_close($ch);
Honestly, I do not understand how I get this data, since there are no parameters.
Any ideas?
source share