微信超时5s,调用客服接口异步回复消息(PHP)

当用户触发事件,如果不能保证在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===============          
//以下为调用客服消息接口,回复用户消息的代码

 

posted @ 2016-12-12 12:20  公主的咖啡屋  阅读(1831)  评论(0编辑  收藏  举报