**Curl 命令不起作用并生成无法识别的错误 **
喜欢
curl: (3) URL rejected: Bad hostname
'-h' is not recognized as an internal or external command, operable program or batch file.
`'-d' 不被识别为内部或外部命令, 可运行的程序或批处理文件。
curl -X POST "https://accounts.spotify.com/api/token" \
-h "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=xxxxxxxxxxxx&client_secret=xxxxxxxxx"
`
我正在尝试在命令提示符中使用 Spotify api 并希望解决无法识别的错误
-h 是获取命令帮助信息的开关
$ curl -h
Usage: curl [options...] <URL>
-d, --data <data> HTTP POST data
-f, --fail Fail fast with no output on HTTP errors
-h, --help <category> Get help for commands
-i, --include Include protocol response headers in the output
-o, --output <file> Write to file instead of stdout
-O, --remote-name Write output to a file named as the remote file
-s, --silent Silent mode
-T, --upload-file <file> Transfer local FILE to destination
-u, --user <user:password> Server user and password
-A, --user-agent <name> Send User-Agent <name> to server
-v, --verbose Make the operation more talkative
-V, --version Show version number and quit
This is not the full help, this menu is stripped into categories.
Use "--help category" to get an overview of all categories.
For all options use the manual or "--help all".
-h 需要一个类别作为子参数
就我而言,我收到此错误
Invalid category provided...
所以你正在尝试使用curl不支持的东西。但你得到的错误取决于分布。
应该是-H而不是-h
curl -X POST "https://accounts.spotify.com/api/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=xxxxxxxxxxxx&client_secret=xxxxxxxxx"