【发布时间】:2010-10-23 05:53:12
【问题描述】:
我可能有点离题,但我整个下午都在尝试在这个课间 PHP 框架教程中运行 the curl post command。我不明白的是 PHP 应该如何解释我的 POST,它总是作为一个空数组出现。
curl -i -X POST -d '{"screencast":{"subject":"tools"}}' \
http://localhost:3570/index.php/trainingServer/screencast.json
(那里的斜线只是为了让我看起来不像个白痴,但我使用 PHP 5.2 从 windows 执行此操作,也在 Linux 服务器上尝试过,与 Linux curl 相同的版本)
我一定缺少一些东西,因为它看起来很简单,只是帖子的解释不正确,如果是,一切都会很好。
这是我回来的:
HTTP/1.1 409 冲突 日期:格林威治标准时间 2009 年 5 月 1 日星期五 22:03:00 服务器:Apache/2.2.8 (Win32) PHP/5.2.6 X-Powered-By: PHP/5.2.6 传输编码:分块 内容类型:文本/html;字符集=iso-8859-1 {"screencast":{"id":null,"subject":null,"body":null, "dataUrl":null,"dataMedium":null,"createdOn":null,"author":null}}【问题讨论】:
-
能否请您也复制粘贴您的 .php 文件?您确定 URL localhost:3570/index.php/trainingServer/screencast.json 运行您的脚本吗?它看起来不像 PHP URL。
-
@pts; Peter 正在使用某种 MVC 框架,请查看该 URL 中的 index.php。
-
@pts 我将 Delphi 用于 PHP(因此是 :3570)和没有 .htaccess 文件的 Recess MVC 框架,因此是 url 中的 index.php/。
-
别忘了发送
application/json。 -
在简单的双引号内嵌入双引号时,不需要转义。