Hey,
I'm using a modified version of lerchmo's cURL class. I'm trying to build proxy support into it, but for some reason the page just DOESN'T LOAD. When I take out the parameters I'm using to make it support a proxy, it does work. I should note that this happens with every proxy I've tried.
Here's the class. The bolded parts are what I'm dealing with now.
I'm using a modified version of lerchmo's cURL class. I'm trying to build proxy support into it, but for some reason the page just DOESN'T LOAD. When I take out the parameters I'm using to make it support a proxy, it does work. I should note that this happens with every proxy I've tried.
Here's the class. The bolded parts are what I'm dealing with now.
Code:
class Curl
{
function setup()
{
$cookieJar = 'cookies.txt';
curl_setopt($this->curl, CURLOPT_COOKIEJAR, $cookieJar);
curl_setopt($this->curl, CURLOPT_COOKIEFILE, $cookieJar);
curl_setopt($this->curl, CURLOPT_AUTOREFERER, true);
curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
[B] curl_setopt($this->curl, CURLOPT_HEADER, 1);
curl_setopt($this->curl, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($this->curl, CURLOPT_PROXY, '122.126.72.145:31413');[/B]
}
function clean($contents)
{
return $contents = str_replace('<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAA6ElvpTmZs4PUpZpSAoK6BSHXJsp5oogWH5jZodYSc2VMsh-GBSvecccQD_seEoYLmo-SsWfitQQEw" type="text/javascript"></script>', '', $contents);
}
function get($url)
{
$this->curl = curl_init($url);
$this->setup();
return $this->clean($this->request());
}
function getAll($reg,$str)
{
preg_match_all($reg,$str,$matches);
return $matches[1];
}
function postForm($url, $fields, $referer='')
{
$this->curl = curl_init($url);
$this->setup();
curl_setopt($this->curl, CURLOPT_URL, $url);
curl_setopt($this->curl, CURLOPT_POST, 1);
curl_setopt($this->curl, CURLOPT_REFERER, $referer);
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $fields);
return $this->request();
}
function getInfo($info)
{
$info = ($info == 'lasturl') ? curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL) : curl_getinfo($this->curl, $info);
return $info;
}
function request()
{
return curl_exec($this->curl);
}
}
$curl = new Curl;
echo $curl->get('http://whatismyip.com/');