curl_init — The first step is to initializes a new session of cURL and return a cURL handle to other functions. curl_setopt — The second step is to set options for a cURL session handle. All these settings are very well explained at curl_setopt(). curl_exec — In third step it perform a cURL session based on above options set. curl_close — The last step is to close a cURL session initialize by curl_init() and free all resources. Also deleted the cURL handle.

Let’s use the below sample code to create a POST request with PHP cURL.

The main thing is that the request must be a POST request with properly json-encoded data in the body. The headers must properly describe the post body.