public function eventByThirdCallbackChat(Request $request)
{
Log::info('用户发送消息:',$request->input());
$easywechat = EasyWechatEnterpriseService::getInstance(0, false);
$app = $easywechat->app;
$server = $app->server;
$server->push(function ($message) use ($app) {
//数据回调
Log::info('数据回调:',$message);
//发给谁
$corpid = $message['ToUserName'];
$enterprise_info = WechatModel::query()->where('app_id', $corpid)->first();
if (empty($enterprise_info)) {
throw new SwarmTipsException(get_tips_data('数据库没有查到该企业!', __FILE__, __LINE__));
}
$token = $message['Token'];
//获取access_token
$access_token = $this->getAccessToken($enterprise_info, $app);
//获取消息类型 发送的消息
$message_info = $this->getMessage($access_token, $token);
$message = array_pop($message_info['msg_list']);
if ($message['msgtype'] == 'event') {
//用户扫码进入消息页面
$external_userid = $message['event']['external_userid'];
$open_kfid = $message['event']['open_kfid'];
} else {
//用户发送消息
$external_userid = $message['external_userid'];
$open_kfid = $message['open_kfid'];
}
//查询用户
$user_info = $this->getUserInfo($external_userid, $access_token, $open_kfid, $enterprise_info);
Log::info('看看是谁发的消息:' . $user_info->username);
//保存最新的消息
$this->getNewMessage($access_token, $token, $user_info);
});
$response = $server->serve();
$response->send();
}
我给微信客服发送了一次消息,就收到了这么多条数据回调 不知道是什么情况...上面是我数据回调的代码
你好,微信客服消息是接收到用户进线时,你们主动拉取的,确认下是否这里的值没有变化,一直拉取的同一个数据