get(); foreach ($medias as $media) { $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$media->app_id}&secret={$media->app_secret}"; $response = \Curl::to($url)->asJson()->get(); if (isset($response->errcode) && $response->errcode != 0) { continue; } $media->access_token = $response->access_token; $media->save(); \DB::connection('mysql_datalog') ->table('koudai.public_access_token') ->where('user_name', $media->user_name) ->update([ 'access_token' => $response->access_token, 'updated_at' => time() ]); } $medias = TokenModel::where('type', 'QQ小程序')->get(); foreach ($medias as $media) { $url = "https://api.q.qq.com/api/getToken?grant_type=client_credential&appid={$media->app_id}&secret={$media->app_secret}"; $response = \Curl::to($url)->asJson()->get(); if (isset($response->errcode) && $response->errcode != 0) { continue; } $media->access_token = $response->access_token; $media->save(); \DB::connection('mysql_datalog') ->table('koudai.public_access_token') ->where('user_name', $media->user_name) ->update([ 'access_token' => $response->access_token, 'updated_at' => time() ]); } } }