1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace App\Listeners;
- use App\Events\UserMessageEvent;
- use Illuminate\Queue\Listener;
- use Illuminate\Support\Facades\Log;
- class UserMessageListener {
- protected $template_id;
- protected $url;
- //审核通知 通知用户审核结果
- public function __construct()
- {
- //szXa-NqOvLHxXzIWqkwB0HiFS3Dp3vz38KXq2nCGDiQ
- $this->template_id='6fKG5UML7jpoQ6p43vV3InYiwH2rLWNVMwSsfSNio3U';
- // $this->template_id='szXa-NqOvLHxXzIWqkwB0HiFS3Dp3vz38KXq2nCGDiQ';
- // $this->template_id='VQY91hiknlZvhTEGfj8fCXb3Jp9ZsM0jeYD9QJ1Osjg';
- $this->url='http://api.app.jiuweiyun.cn/api/gzh';
- }
- public function handle(UserMessageEvent $event)
- {
- try{
- $data=$event->data;
- $openid=$data['openid'];
- $app=app('wechat.official_account');
- $a=$app->template_message->send([
- 'touser' => $openid,
- 'template_id' => $this->template_id,
- 'url' => $this->url,
- 'data' => $data['data']
- ]);
- Log::info(json_encode($a,JSON_UNESCAPED_UNICODE));
- }catch (\Exception $exception){
- Log::error('发送模板消息出错,出错内容为'.$exception);
- }
- }
- }
|