GET请求
带参: curl http://xxxxx?name=value&name2=value2
不带参: curl http://www.baidu.com
巨坑
curl http://localhost:8000/w/d.html?pr=3&rqc=10
无论windows、linux curl这样子居然带不上第二个参数, 实际服务端只接收到第一个, 第二个丢失了, 真是坑
带参: curl http://172.16.102.208:8089/wiapi/score -d "score=19&_test_user=test01"
不带参: curl -X POST http://xxxxx 或 curl http://xxxxxx -d ""
注意:①-d也可以用--data,也就是请求体里的信息
application/json的形式
# 以下在linux中进行的测试,curl版本是7.19.7
# 最简单的调用方式: 1、json值用单引号引起来 2、json值的key不能去掉单引号 3、Content-Type大小写都可以 4、Content-Type和application/json之间可以没有空格
curl http://127.0.0.1:9980/tpl/sendTemplateMsg -H "Content-Type:application/json" -d '{"remark":"stone test","openid":"oVf1K0tNwHQPGWf2gxNQYxruxk84"}'
# 成功调用
curl http://127.0.0.1:9980/tpl/sendTemplateMsg -H "Content-Type:application/json" -d "{\"remark\":\"hhh\",\"openid\":\"oVf1K0tNwHQPGWf2gxNQYxruxk84\"}"
# 成功调用,说明Content-Type不区分大小写
curl http://127.0.0.1:9980/tpl/sendTemplateMsg -H "content-type:application/json" -d "{\"remark\":\"just test\",\"openid\":\"oVf1K0tNwHQPGWf2gxNQYxruxk84\"}"
# 成功调用,说明可以哦那个单引号
curl http://127.0.0.1:9980/tpl/sendTemplateMsg -H "content-type:application/json" -d '{"remark":"just test","openid":"oVf1K0tNwHQPGWf2gxNQYxruxk84"}'
# 失败,说明不能去掉json结构中key的引号
curl http://127.0.0.1:9980/tpl/sendTemplateMsg -H "content-type:application/json" -d '{remark:"just test",openid:"oVf1K0tNwHQPGWf2gxNQYxruxk84"}'
# 失败,说明不能去掉参数值引号
curl http://127.0.0.1:9980/tpl/sendTemplateMsg -H "content-type:application/json" -d {"remark":"just test","openid":"oVf1K0tNwHQPGWf2gxNQYxruxk84"}