當用戶觸發事件,如果不能保證在5s內響應,可以先返回success,然后異步調用返回的信息。代碼如下:
1 // 立即返回(異步執行) 2 ignore_user_abort(true);//start========= 3 ob_start(); 4 echo 'success'; // send the response 5 header('Connection: close'); 6 header('Content-Length: ' . ob_get_length()); 7 ob_end_flush(); 8 ob_flush(); 9 flush();//end===============
//以下為調用客服消息接口,回復用戶消息的代碼