id)->value('openid'); $content = request('content'); $remark= request('remark'); // $openid = 'oVxTzvgYlGktIDZXwfLMLQ01Tr5s'; 自己 if(empty($openid)) continue; // $this->send($openid,$content,$remark); } return $this->response()->success('发送成功')->refresh(); } public function form() { $this->text('title','标题')->value('社区通知')->disable(); $this->textarea('content','内容')->rows(4); $this->textarea('remark','备注')->rows(3); } public function send($open_id,$cotent, $remark) { if(empty($open_id)) return true; $config = [ 'app_id' => 'wx1c2357232cd25f65', 'secret' => 'c8cab53e4e52234ed1bc2abbdeaba57d', // 'app_id' => 'wx13bedfcc62e9bab0', // 'secret' => '175e5518b6426dd12d3096f24ca68fb8', 'response_type' => 'array' ]; $app = Factory::officialAccount($config); $user = $app->user->get('oVxTzvgYlGktIDZXwfLMLQ01Tr5sss'); if(!isset($user['openid'])) return true; $app->template_message->send([ 'touser' => 'oVxTzvgYlGktIDZXwfLMLQ01Tr5s', 'template_id' => '3LUhWGlyiljxrT3Jh8orwQZ2LSHjfRs9SIHaB40O6q0', // 'url' => 'https://t5.9026.com', 'data' => [ 'first'=>'社区通知', 'keyword1' => '王海军', 'keyword2' => 18719141830, 'keyword3' => '开发工程师', 'keyword4' => '思维定制', 'keyword5' => '2020-12-12', ], ]); return true; } public function send2($user_ids,$number,$content){ if(!is_array($user_ids)) { $user_ids = [$user_ids]; } $app = app('wechat.official_account'); foreach($user_ids as $user_id) { $user = (new User())->find($user_id); if(empty($user) || empty($user['open_id'])) continue; $official_open_id = $user->getOfficialOpenId($user['union_id']); if(empty($official_open_id)) continue; $result=$app->template_message->send([ 'touser' => $official_open_id, 'template_id' => '4x80cGpV2boFdY7fm4QpsPBNo-FLytKjQGJKtZq_nr4', 'miniprogram' => [ 'appid' => env('WECHAT_MINI_PROGRAM_APPID'), 'pagepath' => 'pages/index/index', ], 'data' => [ 'first' => '作业许可状态改变', 'keyword1' => $number, 'keyword2' => $content, 'keyword3' => $user->name, 'remark' => '备注' ], ]); var_dump($result); } return true; } }