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可以实现异步,你这样做还是同步的

09-17 13:40