时间:2021-07-01 10:21:17 帮助过:8人阅读
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;
}
?>
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);
你用php 的curl函数不行嘛
用curl应该不行,不过可以在请求地址调用回调。
用swoole这种网络框架可以
$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可以实现异步,你这样做还是同步的