Multicurl Class - How to set options (like Proxy)?

Status
Not open for further replies.

plepco

New member
May 24, 2007
275
11
0
New Orleans
www.massindexer.com
OKay so I downloaded the Multicurl Class from here: Class: MultiCurl (fsockopen) - PHP Classes

I even got it to work. But I cannot figure out how to set Curl options when I use it.

Normally I would include a couple lines in a cURL script like:
curl_setopt ($ch, CURLOPT_PROXY, "99.99.99.999:9999");
curl_setopt ($ch, CURLOPT_PROXYTYPE,CURLPROXY_SOCKS5);


But how the hell do I do it with this Multicurl class?? That is the question.

If anyone can take a look and see, or if anyone is familiar with this class and already knows the answer...please enlighten me!

Thanks
 


From the PHP RTFM site

Code:
         // false proxy used to generate connection error
        $ProxyServer = "116.155.95.163";
        $ProxyPort = 8080;
        $timeout=10;
        echo "Opening ProxyServer $ProxyServer<br>";
        // must use next two statements
        Set_Time_Limit(0);  //Time for script to run .. not sure how it works with 0 but you need it
        Ignore_User_Abort(True); //this will force the script running at the end
        
        $handle = fsockopen($ProxyServer, $ProxyPort,$errno,$errstr,$timeout);        
        if (!$handle){
            echo "Failed to open ProxyServer $ProxyServer errno=$errno,errstr=$errstr<br>";
            return 0;
...
 
Hmm, not sure how the above post solves your problem.

I just downloaded multicurl and have yet to try it personally but it appears it should be structured something like this:

$mc = new MyMultiCurl();
$curlOptions = array();
$curlOptions['CURLOPT_HTTPPROXYTUNNEL'] = 1;
$curlOptions['CURLOPT_PROXY'] = "$proxyHost:$proxyPort";

$mc->setCurlOptions($curlOptions);
 
Hmm, not sure how the above post solves your problem.

I just downloaded multicurl and have yet to try it personally but it appears it should be structured something like this:

$mc = new MyMultiCurl();
$curlOptions = array();
$curlOptions['CURLOPT_HTTPPROXYTUNNEL'] = 1;
$curlOptions['CURLOPT_PROXY'] = "$proxyHost:$proxyPort";

$mc->setCurlOptions($curlOptions);

You'd THINK so...but unfortunately the author of the PHP class didn't give an example of using it with a proxy.

FORTUNATELY however I emailed him and he gave me two usage examples which I now share here:
"
PHP:
$mc = new MyMultiCurl(array(
    CURLOPT_PROXY => "99.99.99.999:9999",
    CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5
));
$mc->addUrl('http://google.com');
$mc->addUrl('http://yahoo.com');
$mc->addUrl('http://altavista.com');
$mc->wait();
........

Or you can set this option for some requests:

$mc = new MyMultiCurl();
$mc->addUrl('http://google.com');
$mc->addUrl('http://yahoo.com', array(
    CURLOPT_PROXY => "99.99.99.999:9999",
    CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5
));
$mc->addUrl('http://altavista.com');"
$mc->wait();
"
 
You just need to read the CURL manual and you'd realize how obvious that was.

All those options you can set with curl_setopt() are for CURL handles. The CURL multihandle contains the single handles and it can too receive some options but those are special options just for the multihandle.

The php binding was one of the first CURL bindings and most of the code is pretty old. I had a chat with a php developer and she told me she plans on adding those options for the multihandle. If you find any bugs in the php binding or need some feature, you can look for Pollita in #curl @ Freenode IRC.
 
Is it possible to dynamically display on page everytime a curlline is execute.

Like run the multicurl and everytime it does something then spit something on the screen.

My scripts always look like they are hanging when i run them so i'd like to make them more alive (so i can also sit down and watch how far it is :) ).

I have on idea how to do this, hopefully somebody can point me out in the right direction. My ajax skillz is still on a noobish level.
 
Status
Not open for further replies.