/**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $access_token = WechatResource::first()->access_token;
     $url = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=" . $access_token;
     $jsonArr = array('filter' => array("is_to_all" => true), "msgtype" => "text", "text" => array("content" => 'Hello World'));
     $json3 = json_encode($jsonArr, JSON_UNESCAPED_UNICODE);
     $res = $this->https_request($url, $json3);
     $result = json_decode($res);
     dd($res);
 }
Exemple #2
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->call(function () {
         $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxbaf45caa5c23134f&secret=404a2a9a33c016775fa48553b259cb2b';
         $json = file_get_contents($url);
         $data = json_decode($json);
         $resource = WechatResource::first();
         $resource->access_token = $data->access_token;
         $resource->save();
     })->hourly();
 }