【问题标题】:How do I send an HTTP POST with curl?如何使用 curl 发送 HTTP POST?
【发布时间】:2011-10-21 18:02:27
【问题描述】:

我正在尝试访问 Google Search Appliance API:http://code.google.com/apis/searchappliance/documentation/612/gdata/acapi_protocol.html

为了发送请求,我使用 curl。我的问题是,当我尝试登录时,使用

curl -k -X POST https://ip.ad.dr.ess:8443/accounts/ClientLogin&Email=username&Passwd=password

我得到以下信息:

'Email' is not recognized as an internal or external command,
operable program or batch file.
Passwd: unknown user =password

对于这个问题的任何帮助将不胜感激。我是 curl 新手,所以我意识到我可能用错了。

我在 Windows 7 上通过 cygwin 安装了 curl。

【问题讨论】:

    标签: curl cygwin http-post google-search-appliance


    【解决方案1】:

    我很确定你必须按照

    curl -k -X POST https://ip.ad.dr.ess:8443/accounts/ClientLogin -d Email=username -d Passwd=passwd
    

    有关命令选项的列表,请参阅 http://curl.haxx.se/docs/manpage.html#-d

    【讨论】:

      【解决方案2】:

      尝试用" 括起您的网址。由于您使用的是 & 和其他特殊的 bash 字符,因此您需要将它们括在引号中。

      这是一个 bash 问题:

      $ curl -k -X POST "https://ip.ad.dr.ess:8443/accounts/ClientLogin&Email=username&Passwd=password"
      

      【讨论】:

        【解决方案3】:

        shell 将 & 字符解释为命令的结尾:您需要将整个 URL 放在引号中

        curl -k -X POST "https://ip.ad.dr.ess:8443/accounts/ClientLogin&Email=username&"
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2014-03-25
          • 2015-01-18
          • 1970-01-01
          • 1970-01-01
          • 2016-07-25
          • 2012-01-03
          • 1970-01-01
          相关资源
          最近更新 更多