3 回答
TA贡献1891条经验 获得超3个赞
Jordans分析为什么没有填充$ _POST-数组是正确的。但是,你可以使用
$data = file_get_contents("php://input");
只需检索http正文并自行处理。请参阅PHP输入/输出流。
从协议的角度来看,这实际上更加正确,因为无论如何你还没有真正处理http多部分表单数据。另外,在发布请求时使用application / json作为内容类型。
TA贡献1848条经验 获得超6个赞
通常,该参数-d被解释为表格编码。你需要-H参数:
curl -v -H "Content-Type: application/json" -X POST -d '{"screencast":{"subject":"tools"}}' \
http://localhost:3570/index.php/trainingServer/screencast.json
TA贡献1780条经验 获得超4个赞
我相信你得到一个空数组,因为PHP期望发布的数据采用Querystring格式(key = value&key1 = value1)。
尝试将您的curl请求更改为:
curl -i -X POST -d 'json={"screencast":{"subject":"tools"}}' \
http://localhost:3570/index.php/trainingServer/screencast.json
并看看这是否有帮助。
- 3 回答
- 0 关注
- 468 浏览
添加回答
举报
