Jump to content

CURLOPT_PROXY failing me?


MySQL_Narb

Recommended Posts

(note: cURL is installed on my webhost)

 

Useful cURL class I'm using: http://paste2.org/3weaghkm

 

 

public function testNewProxies($file, $max_time = 5){
        $proxies = file_get_contents($file);
        $proxies = explode(PHP_EOL, $proxies);
        
        $fresh = array();
        
        foreach($proxies as $proxy){
            $this->curl->addSession('http://www.google.com', array(
                CURLOPT_TIMEOUT => 10,
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_PROXY => $proxy
            ));
        }
        
        $results = $this->curl->exec();
        $this->curl->clear();
        
        print_r($results);
        
        //check for fresh proxies
        for($i = 0; $i < count($proxies); $i++){
            if(strpos($results[$i], 'removed'))
                $fresh[] = $proxies[$i];
        }
        
        //write fresh proxies to new file
        $fh = fopen('proxies/proxies_checked_'.time().'.txt', 'w+');
        
        foreach($fresh as $proxy){
            fwrite($fh, $proxy.PHP_EOL);
        }
        
        fclose($fh);
        
        return count($fresh);
    }

 

The above function will run a file full of proxies and test them to see if they're good for use; however, nothing is ever returned. No errors or any data at all is returned in $results.

 

I always get this:

 

3Bwrq.png

 

or

 

3BwuB.png

 

Any ideas and/or solutions?

 

Thank you. :)

Link to comment
https://forums.phpfreaks.com/topic/280113-curlopt_proxy-failing-me/
Share on other sites

  On 7/13/2013 at 3:01 AM, .josh said:

Your code doesn't show that you're even checking for errors. In your other thread I gave you some tips for looking at errors and header info returned from the curl calls.. Have you tried that? What does it output?

 

Sorry, usually soon as I post my problems I come up with a fix afterwards (should probably wait longer, but yeah).

 

I'm using the built in error function in the CURL class. Added this bit:

$errors = $this->curl->error();
print_r($errors);

3BD8m.png

 

And that was my interesting result. There's no way these are all failing; I just double checked in a proxy checking problem...and quite a bit returned working.

It seems as if the cURL option for the PROXY just doesn't work at all. I tried this with just a regular setup.

 

 

<?php
 
$ch = curl_init('http://www.google.com');
curl_setopt($ch, CURLOPT_PROXY, '123.103.23.106:20400');
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_exec($ch);
print_r(curl_getinfo($ch));
curl_close($ch);
 
?>

 

And it still returned nothing.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.