Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel-Wechat 客服消息接收异常 #40

Open
wilbur-yu opened this issue Jul 27, 2020 · 2 comments
Open

Laravel-Wechat 客服消息接收异常 #40

wilbur-yu opened this issue Jul 27, 2020 · 2 comments

Comments

@wilbur-yu
Copy link
Contributor

接入微信后台的客服api
route/api.php

$router->any('wechat/serve', 'WechatMiniCustomerController@serve');

控制器方法

    public function serve() : Response
    {
        $app = $this->getMiniProgram();

        $customerService = $app->customer_service;

        $app->server->push(static function ($message) use ($customerService) {
            if (isset($message['MsgType']) && 'miniprogrampage' === $message['MsgType']) {
                if ('type=map' === $message['PagePath']) {
                    $text = new Text(AirdropConstant::CUSTOMER_INTRO_TEXT);
                    $customerService->message($text)->to($message['FromUserName'])->send();
                }

                $link = new Link(AirdropConstant::APP_INFO[$message['PagePath']]);
                $customerService->message($link)->to($message['FromUserName'])->send();
            }
        });

        return $app->server->serve();
    }

在转发给客服后, 客户端收到消息延迟或者接收不到或者在一段时间后, 会收到好多条.
替换为支持协程的Guzzle Handler后, 也会有这些问题.
PHP-FPM下是正常的.

@huang-yi
Copy link
Owner

你可以记下日志,调试一下$message的值,看看你的代码有没有走到if代码块里面。我感觉这个和guzzle没有太大关系,可能是参数的问题

@wilbur-yu
Copy link
Contributor Author

日志正常记录接收到微信端的转发请求,但是转发给微信的请求没有记录到日志中,每次重启服务后,会正常一段时间,之后就开始断断续续的出现接受不到消息的情况

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants