使用cURL发布数据时出现"位置参数"错误

kne*_*eki 4 php curl http-post

如果我没有发出命令--data "...",它就可以了.我试过谷歌,我找不到这个问题的任何答案.按照此处的说明,当我尝试使用cURL发布数据时,我遇到以下错误:

PS C:\Users\David> curl --data "SMethod=0" "http://localhost/terra/modules/scripts/Query.php"
Invoke-WebRequest : A positional parameter cannot be found that accepts argument 'SMethod=0'.
At line:1 char:1
+ curl --data "SMethod=0" "http://localhost/terra/modules/scripts/Query.php"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Run Code Online (Sandbox Code Playgroud)

小智 13

Remove-item alias:curl

这会很容易卷曲!!

尝试和乐趣..curl也可以制作自己的 SHORTEN URL,所以不需要与 3rd 方合作.. :D


小智 11

使用命令提示符而不是使用 PowerShell。

如果您使用的是 PowerShell,则需要在curl 命令前添加前缀cmd /c. 例如:

cmd /c curl --data "SMethod=0" "http://localhost/terra/modules/scripts/Query.php"
Run Code Online (Sandbox Code Playgroud)


Phi*_*ick 9

您的问题在这里得到解答:在64位Windows上运行cURL

你没有运行curl你正在运行一个名为Invoke-WebRequest的东西,它被别名卷曲.你需要unalias curl,下载并安装curl(如果你还没有).