<分区>
Possible Duplicate:
How to get body of a POST in php?
我收到一个包含 JSON 的 POST,问题是当我收到 $_POST 为空时。为了测试我何时收到 POST,我创建了一个包含 $_POST、$_GET 和 $_REQUEST 的文件,它们都是空的。
发送请求的客户端正在做这样的事情:
$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);
老实说,我不明白我是如何获得这些数据的,因为没有参数集。
有什么想法吗?