An object-oriented layer to PHP curl functions.
Initialising and configuring a cURL handle in PHP can be sometimes a bit tricky or time consuming, especially when we just need to retrieve a simple page. The goal of the Curl class is to abstract the configuration and error handling, and to offer the user simple methods to do the basic tasks.
Here are few ways to use the class. To see all possible actions, refer to the documentation or source code.
<?php
$Curl = new Curl;
$content = $Curl->get('http://google.com');
<?php
$Curl = new Curl;
$Curl->setFile('content.html');
$Curl->get('http://google.com');
<?php
$Curl = new Curl;
$Curl->setDelay(2); //wait 2 seconds between each request
$content1 = $Curl->get('http://example.com/page1.html');
$content2 = $Curl->get('http://example.com/page2.html');
When performing requests, you will have a user agent by default :
YourBot/1.0 (+http://yourwebsite.com)
You can either modify this string stored in the DEFAULT_USER_AGENT constant or set your user agent at execution :
<?php
$Curl = new Curl;
$Curl->setUserAgent('A more legit user agent');
The documentation can be generated with doxygen. To do it, just type this :
doxygen .Doxyfile