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;}?>
Reply content:
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;}?>
$a=exec($cmd, $output, $exit);
You can't use PHP's curl function.
Curl should not work, but callbacks can be invoked at the request address.
With Swoole, this network framework can
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, curlopt_timeout,10);
$response = curl_exec ($ch);
Swoole can be asynchronous, and you're doing it in sync.