CURL = Client URL Library
cURL is supported on almost all hosting accounts (more info). Most may be wondering "what exactly is CURL" and the aim of this document is to give a brief overview on what CURL is and (hopefully) provide enough of an understanding of CURL so that when a question arises you can provide enough information to guide the customer in the correct direction.
What is CURL?
According to Daniel Stenberg (the creator of the libcurl library) CURL is a library "...that allows you to connect and communicate to many different types of servers with many different types of protocols."
In other words, CURL is a browser for scripting languages (such as PHP) or server functions. Those who are familiar with the *NIX application LYNX may be right at home with CURL's features.
What does CURL allow me to do?
At the time of this writing CURL currently supports connections to remote systems over http, https, gopher, telnet, dict, file, and ldap protocols allowing a script to access information from a remote system as if it were a local file / data stream.
This is important for developers who would like to acquire information from a remote system and present it as if they had the data locally.
How would I use CURL?
The idea behind CURL is that a CURL session is first opened then options are passed though the open session then once finished the CURL session is closed. Below is a PHP example script that will create a CURL session, obtain a file, and include the transport headers from the transfer, and finally write the file to a local file.
For a rough breakdown of the CURL components from the above PHP script see below.
First the CURL Session is established.
$ch = curl_init("http://www.example.com/");
// Have CURL connect to www.example.com via http
Set the options for CURL to follow
curl_setopt($ch, CURLOPT_FILE, $fp);
// With the information that is received, write it to a local file.
// as Defined by $fp = fopen("example_homepage.txt", "w");
curl_setopt($ch, CURLOPT_HEADER, 0);
// Include the transport headers in the data received
Finally, execute the session and close it.
curl_exec($ch);
// curl_exec will execute the entire CURL session commands
curl_close($ch);
// curl_close terminates the CURL session
fclose($fp);
// fclose simply closes the local file which is the output from the CURL session
Where should I go to obtain further information about CURL?
Two sites would be the best to go to for information on CURL's use and functions.
Customers wishing to use CURL should be directed to those sites for coding examples. At the time of this writing all CURL extensions are enabled for use (basic PHP restrictions still apply, but the session options are available).