在linux命令行下curl 提交json数据的问题


我在linux命令行下执行:

   
  curl -i -d '{"user":{"uid":123,"username":"woshishui"},"baseinfo":"afsdaa"} '  http://www.domain.com/index.php
 

而index.php里只有一句print_r($_POST);
执行命令后,为啥显示接收不到数据呢?

   
  HTTP/1.1 200 OK
  
Server: nginx/0.8.54
Date: Fri, 27 Jul 2012 08:29:34 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.3.6

Array
(
)

php shell

白河愁ACE 12 years ago

你post的数据没有参数名,这样写就行

   
  curl -i -X POST -d 'a={"user":{"uid":123,"username":"woshishui"},"baseinfo":"afsdaa"}'  http://www.domain.com/index.php
 

包子2431 answered 12 years ago

Your Answer