🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
要想开启自动回复功能的前提是 **必须要开启微信公众号服务器** #### 微信自动回复流程 1. 用户输入信息 2. 微信接收用户发送信息 3. 微信将用户发送信息发送到 服务器配置的URL中 4. 我们接收微信发送信息 返回想要给用户看到的信息 整个流程 我们只需要做第四步 ``` /** * 开启微信公众号 服务器配置验证 */ public function auth_token() { $app = Factory::OfficialAccount($this->wechat_config); //自定义消息方法 $this->message(); $response = $app->server->serve(); $response->send(); } ~~~ /** * 微信自定义消息 * $message 是用户发送给你的数据包 * $message['content'] 表示微信发送给你的用户消息 */ public function message() { $app = Factory::OfficialAccount($this->wechat_config); $server = $app->server; $server->push(function ($message) { //回复内容 $msg = '这里是返回给用户的信息'; return $msg; }); $server->serve()->send(); } ~~~ ```