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','内容')->value('社区通州')->rows(4); $this->textarea('remark','备注')->value('社区通州')->rows(3); } public function send($open_id,$cotent, $remark) { if(empty($open_id)) return true; $config = [ 'app_id' => 'wx1c2357232cd25f65', 'secret' => 'c8cab53e4e52234ed1bc2abbdeaba57d', // 'app_id' => 'wx1c2357232cd25f65', // 'secret' => 'c8cab53e4e52234ed1bc2abbdeaba57d', // 'app_id' => 'wx13bedfcc62e9bab0', // 'secret' => '175e5518b6426dd12d3096f24ca68fb8', 'response_type' => 'array' ]; $app = Factory::officialAccount($config); $app->template_message->send([ 'touser' => $open_id, 'template_id' => '3LUhWGlyiljxrT3Jh8orwQZ2LSHjfRs9SIHaB40O6q0', 'url' => 'http://47.94.228.245', 'miniprogram' => [ 'appid' => 'wx1c2357232cd25f65', 'pagepath' => 'pages/index/index', ], 'data' => [ 'first'=>'社区通知', 'key1' => $cotent, 'key2' => 18719141830, 'key3' => '开发工程师', 'key4' => '思维定制', 'key5' => '2020-12-12', ], ]); } 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; } }