【发布时间】:2013-11-25 04:53:55
【问题描述】:
我正在使用这个 curl 命令将 json 数据发送到一个 php web 服务,但我在 $_POST 变量中没有得到任何东西。
这里是 curl 命令
curl -X POST -i -H "Content-type: application/json" -c cookies.txt -X POST http://192.168.2.127:8888/json.php -d '{"age":"234","password":"password"}'
这里是php代码。
<?php
header('Content-type: application/json');
var_dump($_POST);
$return_arr = array();
$age = $_POST['age'];
$ageInt = intval($_POST['age']);
$return_arr['age1'] = $age;
var_dump($_POST);
$return_arr['age2'] = $ageInt;
echo json_encode($return_arr);
?>
提前致谢
【问题讨论】: