gpt4 book ai didi

windows - cURL Windows 中的双引号/单引号

转载 作者:可可西里 更新时间:2023-11-01 09:27:51 24 4
gpt4 key购买 nike

我有以下 cURL 请求:

curl -H 'Host: example.com' -H 'Accept-encoding: gzip, deflate' -H 'Accept: /' -H 'User-Agent: iPhone' -H 'Secret-Key: 04d798d5ed2e560fb596bcfc3838fec0' -H 'Date: 2017-04-23T00:57:00.05+0200' -H 'Content-type: application/json' --data-binary '{"RegDate": "2017-04-23", "Username": "JamesRicky", "Password": "0001"}' 'example.com/user'

它在 Linux 上完美运行,但在 Windows 上(使用命令提示符/Powershell),它给了我以下响应:

curl: (6) Couldn't resolve host 'example.com''
curl: (6) Couldn't resolve host 'gzip,'
curl: (6) Couldn't resolve host 'deflate''
curl: (6) Couldn't resolve host '*'
curl: (6) Couldn't resolve host 'iPhone''
curl: (6) Couldn't resolve host '04d798d5ed2e560fb596bcfc3838fec0''
curl: (6) Couldn't resolve host '2017-04-23T00:57'

这是因为命令提示符处理双引号/单引号的方式。在过去的 30 分钟里,我一直在尝试弄清楚如何在 Windows 上对其进行格式化。

我尝试了以下操作:

1.

curl -H "Host: example.com" -H "Accept-encoding: gzip, deflate" -H "Accept: /" -H "User-Agent: iPhone" -H "Secret-Key: 04d798d5ed2e560fb596bcfc3838fec0" -H "Date: 2017-04-23T00:57:00.05+0200" -H "Content-type: application/json" --data-binary ^"{^"RegDate^": ^"2017-04-23^", ^"Username^": ^"JamesRicky^", ^"Password^": "^0001^"}^" ^"example.com/user^"

2.

curl -H "Host: example.com" -H "Accept-encoding: gzip, deflate" -H "Accept: /" -H "User-Agent: iPhone" -H "Secret-Key: 04d798d5ed2e560fb596bcfc3838fec0" -H "Date: 2017-04-23T00:57:00.05+0200" -H "Content-type: application/json" --data-binary \"{\"RegDate\": \"2017-04-23\", \"Username\": \"JamesRicky\", \"Password\": "\0001\"}\" \"example.com/user\"

以上都不行...

关于如何格式化第一个 cURL 请求以使其在 Windows 上运行的任何想法?

最佳答案

在单引号或双引号元素内,使用反斜杠转义额外的单引号或双引号。

根据 https://stackoverflow.com/a/15828662/147637

这在 win 10 命令行上的 curl 上效果很好。

关于windows - cURL Windows 中的双引号/单引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43566075/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com