cURL with Proxy

Status
Not open for further replies.

chatmasta

New member
Jan 7, 2007
2,613
68
0
NYC
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.

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/');
 


I should add that cURL is enabled with SSL.

Code:
libcurl/7.15.3 OpenSSL/0.9.7a zlib/1.2.3 libidn/0.5.6
 
Sorry, I should have posted this.

I resolved it - turns out it's a server issue, I think my host (hostgator) only lets me connet to port 80 or something. It works fine on localhost.
 
Status
Not open for further replies.