2

I'm using multi curl with anonymous proxies, and I want to flag the proxies based on performance and location etc after the curl handle is returned. I've tried curl_getinfo() but that does not return information about the proxy used for that curl handle.

Any ideas? I've thought about maybe a way to identify a particular handle and storing that with the proxy used, then when the handle has fired off and returned via curl_multi_info_read() I can look up the handle via the proxy. Not sure what to use as an identifier though. Doing a dump shows the handle as resource(20), but not sure if that is something I can rely on?

I guess if there was something like getOpt() would be ideal, but i don't see anything like that for a curl handle from the research I have done.

Steffan
  • 307
  • 5
  • 16

2 Answers2

3

Check last version of MultiRequest library. There you can do something like this:

$request = new MultiRequest_Request($url);
$request->setCurlOption(CURLOPT_PROXY, $proxy);
// ...
$curlOptions = $request->getCurlOptions();
list($proxyIp, $proxyPort) = explode(':', $curlOptions[CURLOPT_PROXY]);
phparch
  • 175
  • 7
0

I found a parallel curl class (by Pete Warden), that passes data for multi-curl using the following..

    $this->outstanding_requests[$ch] = array(
        'url' => $url,
        'callback' => $callback,
        'user_data' => $user_data,
        'proxy' => $proxy
    );

When the multi-curl is done, it's able to use the curl handle to hold information via the outstanding requests array. If you're interested in multi-curl check out the class, it sets up everything for you and is very customizable.

Steffan
  • 307
  • 5
  • 16