大约一个小时以来,我一直在尝试向 discord webhook 发送帖子请求,但似乎不知道该怎么做。
我想发送这个:
{
"content": null,
"embeds": [
{
"title": "Test!",
"description": "nooo",
"color": 16777215,
"author": {
"name": "Automated Tool Logging",
"icon_url": "https://discohook.org/static/discord-avatar.png"
}
}
],
"attachments": []
}
到目前为止我已经弄清楚了我必须使用这样的 curl 请求
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data '{"content": null,"embeds": [{"title": "test","description": "temp\ntemp2","color": 16777215,"author": {"name": "Automated Tool Logging","icon_url": "https://discohook.org/static/discord-avatar.png"}}],"attachments": []}' -webhook link-
但当我尝试的时候我得到了
curl: (3) URL using bad/illegal format or missing URL
curl: (3) bad range specification in URL position 2:
[{title:
^
我找不到在 curl 请求中使用嵌入的任何示例。有什么想法可以让它发挥作用吗?
答案1
你必须\
在每个 之前添加"
,否则 会"
结束字符串并导致错误。例如,我在原始帖子中使用的命令如下所示
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{\"content\": null, \"embeds\": [{\"title\": \"test\", \"description\": \"temp temp2\",\"color\": 16777215,\"author\": {\"name\": \"Automated Tool Logging\",\"icon_url\": \"https://discohook.org/static/discord-avatar.png\"}}],\"attachments\": []}" [webhook link]