curl_getinfo($handle["url"], CURLINFO_HTTP_CODE);
и вижу int(0)
и как я понимаю соединение не было установлено и сервер НЕ вернул ответ нормальный (200).curl_error, curl_errno и пробовал также curl_multi_errno
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;
}
public function TestProxy ()
{
$array = [];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://httpbin.org/ip');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
curl_setopt($ch, CURLOPT_PROXY, '11.22.33.44:80');
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
$result = curl_exec($ch);
var_dump($result);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
return $array;
}