2
I have a PHP file that makes a POST request via Curl to another PHP file, I need to put this request inside a loop and make a 10 request at once without worrying about the return, there is a way to make this request without having to wait for the answer to make the next call?
Ex: `
for ($i = 1; $i <= 10; $i++) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "/api/atualizar/$i");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_SSLVERSION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// JSON de retorno
$jsonRetorno = trim(curl_exec($ch));
$resposta = json_decode($jsonRetorno);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$err = curl_errno($ch);
curl_close($ch);
echo "Item $i enviado!";
}
?>`
please see here How to create a Minimum, Complete and Verifiable example
– Alvaro Alves
Do you need to do this with PHP? Let’s say that this language is not so good to work with asynchrony.
– Woss