HTTP Class
This is a wrapper HTTP class that uses either cURL or fsockopen to harvest resources from web. This can be used with scripts that need a way to communicate with various APIs who support REST.
Located in /class.cms_http_request.php (line 25)
Constructor for initializing the class with default values.
Add a cookie to the request
Add request parameters
Add a request header
Clear Everything
Clears all the properties of the class and sets the object to the beginning state. Very handy if you are doing subsequent calls with different data.
Execute a HTTP request
Executes the http fetch using all the set properties. Intellegently switch to fsockopen if cURL is not present. And be smart to follow redirects (if asked so).
Whether to follow HTTP redirects
Get last execution error
Get execution result headers
Get execution result body
Get execution status code
Initialize preferences
This function will take an associative array of config values and will initialize the class variables using them.
Example use:
$httpConfig['method'] = 'GET';
$httpConfig['target'] = 'http://www.somedomain.com/index.html';
$httpConfig['referrer'] = 'http://www.somedomain.com';
$httpConfig['user_agent'] = 'My Crawler';
$httpConfig['timeout'] = '30';
$httpConfig['params'] = array('var1' => 'testvalue', 'var2' => 'somevalue');
$http = new Http();
$http->initialize($httpConfig);
Request Header Exists?
Clear all cookies
Whether to save persistent cookies in subsequent calls
Set basic http authentication realm
Set cookie path (cURL only)
Set maximum number of redirection to follow
Set http method
Set request parameters
Set referrer URL
Set target URL
Set timeout of execution
Set User agent string
Whether to use cookies or not
Whether to use cURL or not
Documentation generated on Sun, 12 Aug 2012 08:38:27 -0600 by phpDocumentor 1.3.2