Answer the question
In order to leave comments, you need to log in
curl_multi_init where is the error?
Good evening,
Please tell me what is my mistake.
Maybe you can’t make two functions in such a request, but probably the error is in another
$headers2 = array(
"Accept: application/json",
"Ocp-Apim-Subscription-Key: 88888888888888",
);
$ch1 = curl_init("https://api.wto.org/qr/v1/wto-agreements/001?locale=en");
$ch2 = curl_init("https://api.wto.org/qr/v1/wto-agreements/002?locale=en");
function ex_curl_setopt1($ch1, int $option1, $val1): void
{
if (!curl_setopt($ch1, $option1, $val1)) {
throw new \RuntimeException("curl_setopt failed: " . curl_errno($ch1) . ":" . curl_error($ch1));
}
}
function ex_curl_setopt2($ch2, int $option2, $val2): void
{
if (!curl_setopt($ch2, $option2, $val2)) {
throw new \RuntimeException("curl_setopt failed: " . curl_errno($ch2) . ":" . curl_error($ch2));
}
}
curl_setopt($ch1, CURLOPT_HTTPHEADER, $headers2);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_HTTPHEADER, $headers2);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
$mh = curl_multi_init();
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
do {
$status = curl_multi_exec($mh, $active);
if ($active) {
curl_multi_select($mh);
}
} while ($active && $status == CURLM_OK);
$data = curl_multi_remove_handle($mh, $ch1);
$data2 = curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);
$data = json_decode($response, true, 999, JSON_THROW_ON_ERROR);
var_dump($response);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question