curl_multi_init with different proxy for each handle?
i want to write a script using 开发者_JS百科curl_multi_init()
but i must have to specify the curl_setopt()
with my proxy only once and not for each handle, there is a way to solve this with different proxy for each handle?
i got the solution, specify the proxy that you want with a new curl_init()
then add a new handle.
$master = curl_multi_init();
$curl_arr[1] = curl_init();
curl_setopt($curl_arr[1], CURLOPT_PROXY, $proxy);
curl_multi_add_handle($master, $curl_arr[1]);
do {
curl_multi_exec($master,$running); //while there are running connections just keep looping
} while($running > 0);
$data = curl_multi_getcontent($curl_arr[1]);
and ect.
精彩评论