Curl based HTTP Client Simple but effective OOP wrapper around Curl php lib. More...
Public Member Functions | |
__construct ($debug=false) | |
Curl_HTTP_Client constructor. | |
init () | |
Init Curl session public. | |
set_credentials ($username, $password) | |
Set username/pass for basic http auth. | |
set_referrer ($referrer_url) | |
Set referrer. | |
set_user_agent ($useragent) | |
Set client's useragent. | |
include_response_headers ($value) | |
Set to receive output headers in all output functions. | |
set_proxy ($proxy) | |
Set proxy to use for each curl request. | |
send_post_data ($url, $postdata, $ip=null, $timeout=10) | |
Send post data to target URL return data returned from url or false if error occured. | |
fetch_url ($url, $ip=null, $timeout=5) | |
fetch data from target URL return data returned from url or false if error occured | |
fetch_into_file ($url, $fp, $ip=null, $timeout=5) | |
Fetch data from target URL and store it directly to file. | |
send_multipart_post_data ($url, $postdata, $file_field_array=array(), $ip=null, $timeout=30) | |
Send multipart post data to the target URL return data returned from url or false if error occured (contribution by vule nikolic, vule@) dink e.net | |
store_cookies ($cookie_file) | |
Set file location where cookie data will be stored and send on each new request. | |
set_cookie ($cookie) | |
Set custom cookie. | |
get_effective_url () | |
Get last URL info usefull when original url was redirected to other location public. | |
get_http_response_code () | |
Get http response code public. | |
get_error_msg () | |
Return last error message and error number. | |
close () | |
Close curl session and free resource Usually no need to call this function directly in case you do you have to call init() to recreate curl public. |
Public Attributes | |
$ch | |
$debug = false | |
$error_msg |
Curl based HTTP Client Simple but effective OOP wrapper around Curl php lib.
Contains common methods needed for getting data from url, setting referrer, credentials, sending post data, managing cookies, etc.
Samle usage: $curl = &new Curl_HTTP_Client(); $useragent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; $curl->set_user_agent($useragent); $curl->store_cookies("/tmp/cookies.txt"); $post_data = array('login' => 'pera', 'password' => 'joe'); $html_data = $curl->send_post_data(http://www.foo.com/login.php, $post_data);
Curl_HTTP_Client::__construct | ( | $debug = false | ) |
Curl_HTTP_Client::fetch_into_file | ( | $url, | |
$fp, | |||
$ip = null , |
|||
$timeout = 5 |
|||
) |
Fetch data from target URL and store it directly to file.
string | url |
resource | value stream resource(ie. fopen) |
string | ip address to bind (default null) |
int | timeout in sec for complete curl operation (default 5) |
Curl_HTTP_Client::fetch_url | ( | $url, | |
$ip = null , |
|||
$timeout = 5 |
|||
) |
fetch data from target URL return data returned from url or false if error occured
string | url |
string | ip address to bind (default null) |
int | timeout in sec for complete curl operation (default 5) |
Curl_HTTP_Client::get_effective_url | ( | ) |
Get last URL info usefull when original url was redirected to other location public.
Curl_HTTP_Client::get_error_msg | ( | ) |
Return last error message and error number.
Curl_HTTP_Client::get_http_response_code | ( | ) |
Get http response code public.
Curl_HTTP_Client::include_response_headers | ( | $value | ) |
Set to receive output headers in all output functions.
boolean | true to include all response headers with output, false otherwise public |
Curl_HTTP_Client::send_multipart_post_data | ( | $url, | |
$postdata, | |||
$file_field_array = array() , |
|||
$ip = null , |
|||
$timeout = 30 |
|||
) |
Send multipart post data to the target URL return data returned from url or false if error occured (contribution by vule nikolic, vule@) dink e.net
string | url |
array | assoc post data array ie. $foo['post_var_name'] = $value |
array | assoc $file_field_array, contains file_field name = value - path pairs |
string | ip address to bind (default null) |
int | timeout in sec for complete curl operation (default 30 sec) |
Curl_HTTP_Client::send_post_data | ( | $url, | |
$postdata, | |||
$ip = null , |
|||
$timeout = 10 |
|||
) |
Send post data to target URL return data returned from url or false if error occured.
string | url |
mixed | post data (assoc array ie. $foo['post_var_name'] = $value or as string like var=val1&var2=val2) |
string | ip address to bind (default null) |
int | timeout in sec for complete curl operation (default 10) |
Curl_HTTP_Client::set_cookie | ( | $cookie | ) |
Set custom cookie.
string | cookie public |
Curl_HTTP_Client::set_credentials | ( | $username, | |
$password | |||
) |
Set username/pass for basic http auth.
string | user |
string | pass public |
Curl_HTTP_Client::set_proxy | ( | $proxy | ) |
Set proxy to use for each curl request.
string | proxy public |
Curl_HTTP_Client::set_referrer | ( | $referrer_url | ) |
Set referrer.
string | referrer url public |
Curl_HTTP_Client::set_user_agent | ( | $useragent | ) |
Set client's useragent.
string | user agent public |
Curl_HTTP_Client::store_cookies | ( | $cookie_file | ) |
Set file location where cookie data will be stored and send on each new request.
string | absolute path to cookie file (must be in writable dir) public |