Windows curl 批处理文件

Windows curl Batch file

我想使用 windows 批处理文件调用 mailgun curl。由于 windows shell 不支持多行,我如何在 windows 批处理文件中执行以下 curl 函数?

curl -s --user 'api:key-xxxxxxxxxx' \
    https://api.mailgun.net/v3/sandboxbxxxxxxxxxxxxx.mailgun.org/messages \
    -F from='user <email@gmail.com>' \
    -F to='user <email@live.com>' \
    -F subject='Hello' \
    -F text='body!' \
    -F attachment=@test.txt \

更新

当我在删除多行后尝试执行命令时,它返回了这个错误:

    curl -s --user 'api:key-xxxxxxxxxx' https://api.mailgun.net/v3/sandboxbxxxxxxxxxxxxx.mailgun.org/messages -F from='user  -F to='user  -F subject='Hello' -F text='body!' -F attachment=@test.txt 0<email@live.com 1>'
The system cannot find the file specified.

PS: 附件在同一目录

谢谢!

简单地放在一行上,将 <> 重定向字符放在 " 之间,或者用 ^:

转义
curl -s --user 'api:key-xxxxxxxxxx' https://api.mailgun.net/v3/sandboxbxxxxxxxxxxxxx.mailgun.org/messages -F from="user <email@gmail.com>" -F to="user <email@live.com>" -F subject='Hello' -F text='body!' -F attachment=@test.txt

您还可以为每个元素创建变量:

set "$ApiKey=api:key-xxxxxxxxxx"
set "$Url=https://api.mailgun.net/v3/sandboxbxxxxxxxxxxxxx.mailgun.org/messages"
set "$From=email@gmail.com"
....

and then 

curl -s --user '%$ApiKey%' %$Url% -F from="user <%$From%>" -F to= ....