我正在使用JSON
Response处理cURL
,但它只是 return NULL
。我不明白我在哪里做错了?
这是我的代码:
<?php
$data = array('name' => 'Hagrid','age' => '36');
$bodyData = array('json' => json_encode($data));
$bodyStr = http_build_query($bodyData);
$url = 'http://bulk10.co.in/curl/index.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','Content-Length: '.strlen($bodyStr)));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyStr);
$result = curl_exec($ch);
echo $result;
?>
索引.php:
<?php
$order_info = json_decode($_POST['json']);
var_dump($order_info);
?>
任何人都可以帮助我为什么我得到NULL
回应?