
Untitled
By: a guest on
May 12th, 2011 | syntax:
PHP | size: 1.40 KB | hits: 144 | expires: Never
private function curl($url, $post_param = null)
{
$ch = curl_init();
$fh = fopen('curl.txt', 'a+');
curl_setopt($ch, CURLOPT_STDERR, $fh);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
if($post_param != null)
{
curl_setopt($ch, CURLOPT_HTTPHEADER, array
(
'Host' => 'tld.com',
'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1',
'Accept' => 'application/json, text/javascript, */*; q=0.01',
'Accept-Language' => 'en-us,en;q=0.5',
'Accept-Encoding' => 'gzip, deflate',
'Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'Keep-Alive' => '115',
'Connection' => 'keep-alive',
'X-Requested-With' => 'XMLHttpRequest',
'Referer' => 'http://tld.com/sendlogin.php'
));
}
else
curl_setopt($ch, CURLOPT_COOKIE, 'hellobar_current=1300711502; hellobar_1300711502_variation=11462');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookie.txt');
curl_setopt($ch, CURLOPT_URL, $url.'?'.$post_param);
$html = curl_exec($ch);
curl_close($ch);
fclose($fh);
return $html;
}