我正在尝试在我的本地服务器上以 PHP 发布一些 JSON 数据。我在下面有以下代码,但它不起作用。我错过了重要的事情吗?
$url = 'http://localhost/mmcv/chart1.php';
//open connection
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADERS,array('Content-Type: application/json'));
$result = curl_exec($ch);