Kendi kullandığım aşağıda ki örnek işinizi görebilir sanırım hocam
// Coklu cUrl Fonksiyon
function __mcUrl($urls = []){
if( is_array($urls) && count($urls) > 0 ){
$mcurl = curl_multi_init();
$curl_opt = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 1,
CURLOPT_FOLLOWLOCATION => 0,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CONNECTTIMEOUT => 20,
CURLOPT_TIMEOUT => 20,
CURLOPT_ENCODING => '',
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => ['accept-language: en', 'cache-control: no-cache'],
);
foreach ($urls as $key => $url) {
$curl[$key] = curl_init();
curl_setopt_array($curl[$key], $curl_opt);
curl_setopt($curl[$key], CURLOPT_URL, $url);
curl_multi_add_handle($mcurl, $curl[$key]);
}
$mcurl_run = null;
do{
curl_multi_exec($mcurl, $mcurl_run);
}while ( $mcurl_run > 0 );
$items = [];
foreach ($urls as $key => $url) {
$url_error = curl_error($curl[$key]);
$url_data = curl_multi_getcontent($curl[$key]);
$items[$key] = (object)array(
'status' => $url_data && empty($url_error) ? true : false,
'key' => $key,
'url' => $url,
'error' => $url_error,
'data' => $url_error ? '' : $url_data,
);
curl_multi_remove_handle($mcurl, $curl[$key]);
}
curl_multi_close($mcurl);
return (object)$items;
}
return false;
}
// Kullanım
$urls = ['https://google.com', 'https://twitter.com'];
$urls_data = __mcUrl($urls);
// Return data
/*
stdClass Object
(
[0] => stdClass Object
(
[status] => 1
[key] => 0
[url] => https://google.com
[error] =>
[data] => '.....'sitedata.....'
)
[1] => stdClass Object
(
[status] => 1
[key] => 1
[url] => https://twitter.com
[error] =>
[data] => '.....'sitedata.....'
)
)
*/