Rest 如何从CLI CURL';请求的输出

Rest 如何从CLI CURL';请求的输出,rest,curl,command-line-interface,Rest,Curl,Command Line Interface,有很多关于如何防止curl在请求PHP版本时显示头信息的信息,但对于CLI版本似乎没有 我的请求在表格中 curl -i -X POST -H 'Content-Type: application/json; charset=UTF-8' -H 'X-Accept: application/json' -H '-d '{"somedata":"12ihiuhihihed994f63dbef6b012b"}' https://myurl.com/v3/oauth/request 它可以工作,但返

有很多关于如何防止curl在请求PHP版本时显示头信息的信息,但对于CLI版本似乎没有

我的请求在表格中

curl -i -X POST -H 'Content-Type: application/json; charset=UTF-8' -H 'X-Accept: application/json' -H '-d '{"somedata":"12ihiuhihihed994f63dbef6b012b"}' https://myurl.com/v3/oauth/request
它可以工作,但返回以下内容:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json
Date: Wed, 27 Mar 2013 20:42:11 GMT
P3P: policyref="/w3c/p3p.xml", CP="ALL CURa ADMa DEVa OUR IND UNI COM NAV INT STA PRE"
Server: Apache/2.2.23 (Amazon)
Status: 200 OK
X-Powered-By: PHP/5.3.20
Content-Length: 54
Connection: keep-alive

{"code":"jkhjhhjhaa","state":null}
当我真正想要的是:

{"code":"jkhjhhjhaa","state":null}

只需从
curl
命令中删除
-i
开关即可

man curl
他说:

-i、 --包括
(HTTP)在输出中包括HTTP头。HTTP头包括服务器名称、文档日期、HTTP版本等内容


为了抑制CURL CLI的输出,可以使用silent选项。当curl输出也通过管道传输时,它可以完美地工作

-s, --silent        Silent mode (don't output anything)

如果这不明显,也不要将-v(verbose)开关与-s(silent)一起使用

虽然删除-i选项就足够了,但选项-D也会使标题出现在输出中。在我的curl命令中-i开关不存在,但它仍然在打印标题。