ホームページ > に質問 > 本文
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<code>
function request($url, $payload) {
function
request(
$url
,
$payload
) {
$cmd = "curl -X POST -H 'Content-Type: application/json'";
$cmd
=
"curl -X POST -H 'Content-Type: application/json'"
;
$cmd.= " -d '" . $payload . "' " . "'" . $url . "'";
.=
" -d '"
.
"' "
"'"
if (!$this->debug()) {
if
(!
$this
->debug()) {
$cmd .= " > /dev/null 2>&1 &";
" > /dev/null 2>&1 &"
}
//发送异步请求
exec($cmd, $output, $exit);
exec
(
$output
$exit
);
return $exit == 0;
return
== 0;
?></code>
伊谢尔伦2017-04-11 10:44:52
<code>$a=exec($cmd, $output, $exit);</code>
$a
);</code>
迷茫2017-04-11 10:44:52
你用php 的curl函数不行嘛
用curl应该不行,不过可以在请求地址调用回调。用swoole这种网络框架可以
PHP中文网2017-04-11 10:44:52
$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);
天蓬老师2017-04-11 10:44:52
swoole可以实现异步,你这样做还是同步的