This post has a solution for sending aysnc requests by using forked curl requests:
private function request($url, $payload) {
$cmd = "curl -X POST -H 'Content-Type: application/json'";
$cmd.= " -d '" . $payload . "' " . "'" . $url . "'";
if (!$this->debug()) {
$cmd .= " > /dev/null 2>&1 &";
}
exec($cmd, $output, $exit);
return $exit == 0;
}
It also has a solution where you write to a socket before immediately closing it (before you get a response):
private function request($body) {
$protocol = "ssl";
$host = "api.segment.io";
$port = 443;
$path = "/v1/" . $body;
$timeout = $this->options['timeout'];
try {
# Open our socket to the API Server.
$socket = fsockopen($protocol . "://" . $host, $port,
$errno, $errstr, $timeout);
# Create the request body, and make the request.
$req = $this->create_body($host, $path, $content);
fwrite($socket, $req);
# ...
} catch (Exception $e) {
# ...
}
}