Notice: 函数 WP_Scripts::localize 的调用方法不正确$l10n 参数必须是一个数组。若要将任意数据传递给脚本,请改用 wp_add_inline_script() 函数。 请查阅调试 WordPress来获取更多信息。 (这个消息是在 5.7.0 版本添加的。) in /data/www/appblog/wp-includes/functions.php on line 6131

curl 模拟GET与POST请求,以及上传文件

curl GET 请求

curl http://localhost:8080/api/user/list

curl http://localhost:8080/api/user/list -v

-v表示查看详细的请求信息

curl POST 请求

可以使用-X POST申明请求方法,-d传送参数

curl http://localhost:8080/api/article -X POST -d "title=title&homepage=AppBlog.CN"

这是一个普通的post请求,一般我们的接口都是json格式的,可以用-H参数申明请求的header

curl http://localhost:8080/api/article -X POST -H "Content-Type:application/json" -d '{"title":"title","homepage":"AppBlog.CN"}'
curl http://localhost:8080/email/send/async -X POST -H "Content-Type:application/json" -d '{"to":"test@iobeta.com","subject":"test","content":"content"}'

我们可以利用-H来设置更多的header,比如用户的token之类的

curl http://localhost:8080/api/article -X POST -H "Content-Type:application/json" -H "Authorization:Bearer xxx" -d '{"amount":"10.8"}'

curl POST 上传文件

curl指定参数-F "file=@__FILE_PATH__"即可传输文件:

curl http://localhost:8000/api/upimg -F "file=@/home/yezhou/test.png" -H "token: xxx" -v
上一篇 VirtualBox采坑记录
下一篇 无需绑定设备,下载Google Play上的某个apk文件