1Dec/091
Using cURL Within PHP
PHP includes an easy to use interface for the cURL library. This means you can easily communicate with other servers using a variety of protocols. It is commonly used to access web service APIs such as Twitter. This tutorial will explain the basics and show some usage examples.
There are 4 main functions you need to know to use cURL: curl_init, curl_setopt, curl_exec, and curl_close. The process generally goes like this:
- start a cURL session and get a handle (curl_init)
- set the options for the session (curl_setopt)
- execute the session (curl_exec)
- close the session (curl_close).
The handle returned by curl_init is used as the first parameter in the other functions.
All the available options are listed on the curl_setopt manual page with detailed descriptions.
