请教一下,我用 curl -d 提交内容到企业微信机器人。内容有引用变量,变量值里面带有空格。使用 curl 提交会报错。请问这个有什么好的解决方法。
请教一下,我用 curl -d 提交内容到企业微信机器人。内容有引用变量,变量值里面带有空格。使用 curl 提交会报错。请问这个有什么好的解决方法。
|
msg7086Jul 15, 2020
1
只看你说的这些,我只能回答:根据报错信息对应修改了。
如果多贴点信息的话可能更好地帮助你。 |
|
hush3Jul 15, 2020
2
%20?
|
|
momocraftJul 15, 2020
3
学习 shell 的引号 escape?
|
|
ai277014717Jul 15, 2020
6
加引号
|
|
7
> man curl
--data-urlencode <data> (HTTP) This posts data, similar to the other -d, --data options with the exception that this performs URL-encoding. |
|
megatron7Jul 15, 2020
8
处理过类似的
"content": "'"$1"'" 用引号包裹内容 |
|
lxk11153Jul 15, 2020
10
> curl -s --data-urlencode "a=& &" "b=$your" https://httpbin.org/post
{ "form": { "a": "& &" } "headers": { "Content-Type": "application/x-www-form-urlencoded" } } 你可以换到 `-d` 看看区别,(如果你的内容包含&等特殊字符的话 |
|
lxk11153Jul 15, 2020
11
fix 少打了一个
curl -s --data-urlencode "a=& &" --data-urlencode "b=$your" url |