Thursday, January 22, 2009

What are cURL and libcurl?

cURL stands for "Client URLs" is a function library, and was developed by Daniel Stenberg in 1998 as a command line tool. PHP supports it through libcurl. libcurl is a portable library that provides an easy interface to the cURL functionality. It is thread safe, IPv6 compatible, and supports persistent connections. The libcurl PHP binding was added by Sterling Hughes.

PHP supports libcurl, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.
Requirements
In order to use PHP's CURL functions you need to install the libcurl package. PHP requires that you use libcurl 7.0.2-beta or higher. In PHP 4.2.3, you will need libcurl version 7.9.0 or higher. From PHP 4.3.0, you will need a libcurl version that's 7.9.8 or higher. PHP 5.0.0 requires a libcurl version 7.10.5 or greater.

The following are the basic steps when we process with libcurl from within PHP
Initialize the cURL session : - we initialize a CURL session using the curl_init().
Set the cURL options (The order of the options is not important) : - Then we can set all our options for the transfer via the curl_setopt(),
Execute the options in the cURL session : - we execute the session with the curl_exec()
Close the curl session : - we finish session using the curl_close().


There are more number of functions associated with this libcurl library. Which are
curl_close -- Close a CURL session
curl_copy_handle -- Copy a cURL handle along with all of its preferences
curl_errno -- Return the last error number
curl_error -- Return a string containing the last error for the current session
curl_exec -- Perform a CURL session
curl_getinfo -- Get information regarding a specific transfer
curl_init -- Initialize a CURL session
curl_multi_add_handle -- Add a normal cURL handle to a cURL multi handle
curl_multi_close -- Close a set of cURL handles
curl_multi_exec -- Run the sub-connections of the current cURL handle
curl_multi_getcontent -- Return the content of a cURL handle if CURLOPT_RETURNTRANSFER is set
curl_multi_info_read -- Get information about the current transfers
curl_multi_init -- Returns a new cURL multi handle
curl_multi_remove_handle -- Remove a multi handle from a set of cURL handles
curl_multi_select -- Get all the sockets associated with the cURL extension, which can then be "selected"
curl_version -- Return the current CURL version
curl_setopt -- Set an option for a CURL transfer

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home