POST JSON данные через CURL и захват их
Я пытаюсь передать данные JSON в качестве параметра для CURL POST. Тем не менее, я застрял в том, чтобы схватить его и сохранить на БД.
файл cURL:
$data = array("name" => "Hagrid", "age" => "36");
$data_string = json_encode($data);
$url = 'http://localhost/project/test_curl';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json')
);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$result = curl_exec($ch);
//based on http://www.lornajane.net/posts/2011/posting-json-data-with-php-curl
файл test_curl:
$order_info = $_POST; // this seems to not returning anything
//SAVE TO DB... saving empty...
Что я пропустил? Weew ....