public function MultiRequest ($data)
{
$multi = curl_multi_init();
$handles = [];
$array = [];
foreach ($data as $key)
{
$ch = curl_init();
$url = "https://httpbin.org/ip";
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36",
CURLOPT_PROXY => $key["Ip"] . ':' . $key["Port"],
CURLOPT_PROXYTYPE => CURLPROXY_HTTP,
CURLOPT_TIMEOUT => 50,
CURLOPT_CONNECTTIMEOUT => 50,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_ENCODING => 'gzip, deflate'
));
curl_multi_add_handle($multi, $ch);
$handles[] = array(
'url' => $ch,
'Ip' => $key["Ip"],
'QtyVerifyTime' => $key["QtyVerifyTime"]
);
}
$active = null;
do {
$mrc = curl_multi_exec($multi, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($multi) == -1) {
usleep(10000);
// continue;
}
do {
$mrc = curl_multi_exec($multi, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
foreach ($handles as $handle)
{
$result = curl_multi_getcontent($handle["url"]);
$statusCode = curl_getinfo($handle["url"], CURLINFO_HTTP_CODE);
var_dump($statusCode); // выдает int(0)
if (curl_error($handle["url"])) {
echo curl_error($handle["url"]); // ошибок нет!
}
if (curl_errno($handle["url"])) {
echo curl_errno($handle["url"]); // ошибок нет!
}
curl_multi_remove_handle($multi, $handle["url"]);
}
curl_multi_close($multi);
return $array;
}