根据setMyCommands
,我试图通过curl
调用this answer API。我第一次尝试
curl -L -X "POST" \
"https://api.telegram.org/bot$TELEGRAM_TOKEN"'/setMyCommands?commands=[{ "command": "command", "description": "description" }]'
curl
打印了以下错误。
curl: (3) bad range specification in URL position
然后,我尝试使用带有curl
标志的--globoff
。
curl --globoff -L -X "POST" \
"https://api.telegram.org/bot$TELEGRAM_TOKEN"'/setMyCommands?commands=[{ "command": "command", "description": "description" }]'
现在它打印了以下错误。
curl: (3) URL using bad/illegal format or missing URL
正确的称呼方法是什么?
发布于 2022-04-26 08:56:45
我猜你在用Windows。试试这个:
curl -X POST -H "Content-Type: application/json" -d "{\"commands\":[{\"command\":\"test\",\"description\":\"description with spaces\"}]}" https://api.telegram.org/bot$TELEGRAM_TOKEN/setMyCommands
诀窍是用反斜杠避开JSON中的双引号。它甚至适用于您使用的命令,在查询中发送命令,但是使用-d
(快捷方式为--data
)选项使在命令的描述中包含空格变得更容易。
https://stackoverflow.com/questions/72008615
复制相似问题