Many a times while developing sites we would need to post data to an external server, for example if you have an ecommerce site and wants to manage CRM in a different server at such time you would need to pass the order details to different server. We can POST the data using CURL or drupal_http_request().
cURL
cURL is a very powerfull system which allows us to transfer data across a wide variety of protocols. cURL is commonly used to send data across websites which includes API interaction. Using a cURL request, we can do the basic HTTP request, the more complex FTP upload or interaction with an authentication enclosed HTTPS site. In this section we will go through how cURL is intialized, how to send cURL request and close the requests.
By default, all HTTP requests made out by cURL are GET requests. It simply fetches the URL and doesn't submit any POST variables. However, if we need to fetch and retrieve URL by the POST method with cURL, you will need the snippet below: