Curl Post Request

The basic function of curl post request is first you initialize a session using the curl_init() function ans then set all option for transfer through curt_setopt() function then and the execute your session with curl_exec() function and after all finish your request usingcurl_close() function.

A Simple Curl Post Http request 

<?php

// initialize session
$ch = curl_init(); 

//url using for request
curl_setopt($ch, CURLOPT_URL,"http://www.example.com");

//request mehod
curl_setopt($ch, CURLOPT_POST, 1);

//number of field want to 
curl_setopt($ch, CURLOPT_POSTFIELDS,"postvar1=value1&postvar2=value2&postvar3=value3");

//for receive response of server
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// session executed and hold response in $server_response variable
$server_response = curl_exec ($ch);

?>

4 Replies to “Curl Post Request”

  1. Thanks a lot for providing individuals with an extraordinarily wonderful opportunity to check tips from this web site. It is usually very pleasing and as well , jam-packed with a lot of fun for me and my office mates to search the blog at the least three times in a week to read the latest secrets you have got. And indeed, I am also at all times happy with all the eye-popping information you give. Some 1 tips in this article are unequivocally the very best I have had.

  2. Pingback: Google

Leave a Reply

Your email address will not be published. Required fields are marked *