Using CURL and PHP


CURL is built-in to the usual up-to-date PHP distributions. (You may need to ebale it in php.ini). CURL lets you programmatically transfer files using all the usual protocols, such as HTTP and FTP. Among other things, it lets you write PHP to simulate posting forms. In other words, it's useful for some test scripts. And it is free, open-source code.

You'll find plenty of info about CURL on the web which I won't attempt to reproduce. A good starting point is I'm indebted to smart-guy Richard Garbutt at altcom, for pointing me in this direction.

CURL and PHP - Setup

Assuming you already have PHP5 set up, (PHP4 probably OK too), then simply visit PHP.INI and remove the semi-colon in front of


and restart Apache.

CURL Usage

This example is copied verbatim from, all credit due.

// A very simple PHP example that sends a HTTP POST to a remote site

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,

curl_exec ($ch);
curl_close ($ch); 

I was using something similar to provide form inputs to the Drupal Skills database, which I built for altcom.

Top of page