I have the following test code:
$url = "https://MyAPIdomain/MyAPIendpoint.php";
$contenttype = "Content-Type:application/json";
$postfields = array("ordernumber" => 6392842);
$postfields = json_encode(json_encode($postfields));
$command = 'curl --header "'.$contenttype.'" --request POST --data '.$postfields.' '.$url;
exec($command." > E:/websites/wmfltdonline/subdomains/smartwaste/www/logs/error.txt");
The exec()
works fine, except that it is waiting for a response from the call before continuing. Having read around on this I was expecting the exec()
to fork the process and continue.
Is it possible to use exec()
as a ‘fire and forget process’ for a CuRL POST? In this case I am calling an external API with a parameter that will invoke a process that is self-contained, takes a long time and required no user response.