请教关于linux curl的用法? 使用curl发送POST请求,但是数据是字典形式的字符串,

命令 curl -x POST "http://xxx" -H xxxxx -d '{\"a('c)\"}' ,c前面是个单引号,结果报")"有错,然后改成curl -x POST "http://xxx" -H xxxxx -d '{\"a(\'c)\"}' , 这样还是报一样的错,只看-d后面, 转义符好像没起作用,请大神指点。 只关注-d后面,去掉c前面那个单引号,执行就是OK的。

1.wget

wget --post-data="user=user1&pass=pass1&submit=Login" http://domain.com/path/page_need_login.php

2.curl (可直接发送格式化请求例如json)
提交json数据需要加header,否则需'json={"phone":"13521389587","password":"test"}’
curl -H "Content-type: application/json" -X POST -d '{"phone":"13521389587","password":"test"}' http://domain/apis/users.json

普通请求
curl $URL -d "2880[]=105&pid=2880&p=最佳&count=1&receipt=1&poll=投票"

结果Array( [2880] => Array ( [0] => 105 )
[pid] => 2880 [p] => 最佳 [count] => 1 [receipt] => 1 [poll] => 投票)
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网