如何用curl写帖子

时间:2013-07-16 11:34:08

标签: post curl

我需要在终端上执行以下信息。任何人都可以告诉我如何用卷曲写这个?

POST /shopgate/api.php HTTP/1.1         
User-Agent: Shopgate     
Host: ihrshop.com     
Accept: */*     
X-Shopgate-Auth-User: 12345-1329146130     
X-Shopgate-Auth-Token: 07c573bcaf4e1b4669c3dd23175d78fcfab4e5b4     
Content-Length: 80     
Content-Type: application/x-www-form-urlencoded

2 个答案:

答案 0 :(得分:1)

curl有一个--header选项。 man curl有详细信息。

答案 1 :(得分:0)

你的问题不太清楚。但是,我正在为你提供一些可能对你有帮助的好答案。

如果您想通过POST发送数据,则可以使用此功能。

curl_setopt($ch, CURLOPT_POST ,1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);

$post将是您要发送的字段。

如果您想要标题'info

POST /shopgate/api.php HTTP/1.1         
User-Agent: Shopgate     
Host: ihrshop.com     
Accept: */*     
X-Shopgate-Auth-User: 12345-1329146130     
X-Shopgate-Auth-Token: 07c573bcaf4e1b4669c3dd23175d78fcfab4e5b4     
Content-Length: 80     
Content-Type: application/x-www-form-urlencoded

然后你最好说出来。

curl_setopt($curl, CURLOPT_HEADER, $header);

$header是获取此信息的BOOLEAN值。

如果您需要更多帮助,我会很高兴:)