user2587123
user2587123

Reputation: 13

How to write post in curl

I need to execute the information below on my terminal. Can anyone please tell me how to write this in 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

Upvotes: 1

Views: 164

Answers (2)

Black0CodeR
Black0CodeR

Reputation: 787

Your question is not quite clear. But, I'm providing you with some good answer that might help you.

If you want to send data through POST, then you can use this.

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

$post will be the fields you want to send.

if you want the headers' 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

then you better need to state it.

curl_setopt($curl, CURLOPT_HEADER, $header);

$header is BOOLEAN value to get this info or not.

If you need more help, I'll be happy :)

Upvotes: 0

user2587106
user2587106

Reputation: 325

curl has a --header option. man curl has the details.

Upvotes: 1

Related Questions