I am creating an API that receives a post request and then returns data. This data needs to be returned immediately but then I need to execute a long running curl operation after that.
<?php
if (!empty($_POST)) {
$numbers = isset($_POST['numbers']) ? $_POST['numbers'] : 0;
$numbers = $numbers*$secrethash;
$result = array("error" => false,
"numbers" => $numbers);
echo json_encode($result);
$curlfunction($numbers);
exit;
Unfortunately, data is not returned until the curl function completes which causes my application to timeout. It is possible to execute the curl in the background so my data can be returned immediately?