http post 请求 curl

http post request curl

我在这个网站上发出了 http post 请求 http://requestmaker.com/

我的问题是如何使用 curl 或其他类似的命令行应用程序发出此请求? windows 或 linux 无关紧要。

我的请求URL是这样的:

http://www.website.net/servers?server%5Bgame%5D=cstrike1&server%5Bdomain%5D=192.168.1.1&server%5Bport%5D=27000

请求Headers:

Content-Type: application/json
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Refer: http://www.website.net/servers/new

那就是:

curl -H "Content-Type: application/json" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" -H "Accept-Language: en-US,en;q=0.5" -H "Accept-Encoding: gzip, deflate" -H "Refer: http://www.website.net/servers/new" "http://www.website.net/servers?server%5Bgame%5D=cstrike1&server%5Bdomain%5D=192.168.1.1&server%5Bport%5D=27000"

但我认为您打算设置 Referer header 而不是 Refer 并且您可能应该 POST JSON 数据,因为 Content-Typeapplication/json.