使用easywechat給關注公眾號使用者發訊息

雲123321發表於2020-11-16

使用easywechat給關注公眾號使用者發訊息

	//獲取暱稱
	private function getnickname($openid='')
	{
	     $nickname=DB::name('member')->where(['openid'=>$openid])->value('member_nickname');
	     return $nickname;
	}
   //獲取評論人暱稱
           $nickname=$this->getnickname($openid);
           
             //傳送推送訊息
            $tslist=DB::name('publicgzh')->field('gzhopenid')->where(['member_admin'=>1])->select()->toArray();
            if(!empty($tslist))
            {
                foreach ($tslist as $key=>$val)
                {
                    $noccontent='客戶已完成評分,請檢視';
                    // send_template_message($val['openid'],'MGc0DCmXGA3DQkRhJMozVmVCRRtxDnhjQ9yD27591rw','pages/view_ass/view_ass?openid='.$openid,$noccontent,'張三');//
                    //公眾號發訊息
                    $res=$this->app->template_message->send([
                        'touser' => $val['gzhopenid'],
                        'template_id' => 'bSE7MakcVR6UNJjJYOwdyz9XyqBEpDNdcutwGIWcIKk',
                        'url' =>Config('app.Domain'),
                        'miniprogram' => [
                                'appid' =>Config('app.WeiXinAPPID'),
                                'pagepath' => 'pages/view_ass/view_ass?openid='.$openid,//
                               // 'page' => 'pages/home/home?openid='.$openid,//
                                  
                        ],
                        'data' => [
                            'first' => '客戶考核通知',
                            'keyword1' =>$nickname, //'張三',
                            'keyword2'=>$noccontent,
                            'remark'=>'請檢視詳情!',
                        ],
                    ]);                   
                    
                    file_put_contents('./33.txt',var_export($res,'true'));                    
                }
            }

注意:
在公眾號平臺需要關聯小程式

相關文章