Всем привет! Вопрос возник по curl... какое-то странное поведение.
В общем есть код:
public static function open_httppost($url, $method = 'curl')
{
if($method == 'curl' && function_exists('curl_init'))
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$result = curl_exec($ch);
curl_close($ch);
}
else
{
$result = file_get_contents($url);
}
return $result;
}
и
$datalistPosts = [
'forum' => $disqusapishort,
'thread' => 'link:'.$urllistPosts,
'api_key' => $disqusapipublic
];
$url = 'https://disqus.com/api/3.0/threads/listPosts.json?'. http_build_query($datalistPosts,null,'&');
if (!empty($urllistPosts)) {
$responce = MyjbzoostatHelper::open_http($url, $method);
$listPosts = json_decode($responce, true);
if ($listPosts['code'] == 13) {
echo "<p class='bg-danger' align='center'><small>Превышен лимит Disqus, необходимо немного подождать.</small></p>";
}
else {
jbdump($listPosts,0,'$listPosts');
}
}
else {
echo "<p class='bg-danger' align='center'><small>Введите ссылку сайта, чтобы узнать детальную информацию Disqus.</small></p>";
}
Все отлично работает. в jbdump отлично смотрится. Но вот при мульте:
public static function open_multi($url)
{
if(function_exists('curl_init'))
{
// create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();
// $ch3 = curl_init();
// $ch4 = curl_init();
// $ch5 = curl_init();
// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, $url);
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, $url);
curl_setopt($ch2, CURLOPT_HEADER, 0);
// curl_setopt($ch3, CURLOPT_URL, $url);
// curl_setopt($ch3, CURLOPT_HEADER, 0);
// curl_setopt($ch4, CURLOPT_URL, $url);
// curl_setopt($ch4, CURLOPT_HEADER, 0);
// curl_setopt($ch5, CURLOPT_URL, $url);
// curl_setopt($ch5, CURLOPT_HEADER, 0);
//create the multiple cURL handle
$mh = curl_multi_init();
//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
// curl_multi_add_handle($mh,$ch3);
// curl_multi_add_handle($mh,$ch4);
// curl_multi_add_handle($mh,$ch5);
$active = null;
//execute the handles
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
// curl_multi_remove_handle($mh, $ch3);
// curl_multi_remove_handle($mh, $ch4);
// curl_multi_remove_handle($mh, $ch5);
$result = $mrc;
curl_multi_close($mh);
}
return $result;
}
и так:
//код
$responce = MyjbzoostatHelper::open_multi($url);
$blacklist = json_decode($responce, true);
if ($blacklist['code'] == 13) {
echo "<p class='bg-danger' align='center'><small>Превышен лимит Disqus, необходимо немного подождать.</small></p>";
}
else {
jbdump($blacklist,0,'$blacklist');
}
все просто вываливается:

Большие подозрения - что я в мульти намудрил. Как-то не присвоил значение чтоли...













