template_id='Y5bxIakuAeNkzj1ypnhmQBP4bs0086Z5hYgAtpMiQR8'; $this->url='http://api.app.jiuweiyun.cn/api/gzh'; // $this->template_id='dA1a7THXIf0Pt_WpCW235XV8mw8f0HF7JLgRyk_g8_I'; // $this->url='http://api.woaidakele.cn/api/gzh'; } /** * Handle the event. * * @param AgentIncome $event * @return void */ public function handle(AgentIncome $event) { Log::error(json_encode($event)); try{ $data=$event->data; $openid=$data['openid']; $config=config('wechat.official_account.default'); $app = Factory::officialAccount($config); $app->template_message->send([ 'touser' => $openid, 'template_id' => $this->template_id, 'url' => $this->url, 'data' => $data['data'] ]); }catch (\Exception $exception){ Log::error('发送模板消息出错,出错内容为'.$exception); } } }