Yet Another Curl Library - an open source curl library for PHP
void __construct([array $config]);
string get(string $url);
string post(string $url, array $param, [int $type = 0], [bool $use_http_build_query = true]);
Note: [squared $arguments] are optional
$config = array(
'cookie_prefix' => 'mypref',
'follow_location' => 'true',
'debug' => 'true'
);
$curl = New YACurL($config);
$curl->get('www.mysite.com');
//post encoded as application/x-www-form-urlencoded
$curl->post('www.mysite.com', array('user' => 'myuser', 'pass' => 'mypass'));
//post encoded as multipart/form-data
$response = $curl->post('www.mysite.com', array('user' => 'myuser', 'pass' => 'mypass'), 1);
echo $response;
//static delay
$config = array('delay' => 5);
$curl = New YACurL($config);
//random delay from 1 to 5 seconds
$config = array(
'delay' => array(1,5);
);
$curl = New YACurL($config);
$this->load->library('yacurl', $config);
$this->yacurl->get('www.mysite.com');
If $use_http_build_query is false, form param will be encoded by internal routine instead of http_build_query().
This custom routine is similar to http_build_query() but ignores "*" char.
Example:
- http_build_query('abc*def g') = abc%2Aef%20g
- Internal routine encodes it as abc*def%20g.
- (array) header
- (string) encoding
- (string) cookie_prefix
- (bool) auto_referer
- (bool) return_transfer
- (bool) follow_location
- (int) delay
- (bool) debug
Default:
$_curl_config = array(
'header' => array(
'User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
'Accept-Language: it-IT',
'Accept-Encoding: gzip,deflate,sdch'
),
'encoding' => 'gzip',
'cookie_prefix' => '',
'auto_referer' => true,
'return_transfer' => true,
'follow_location' => false,
'delay' => 0,
'debug' => true
);