|
|
|
@ -46,6 +46,23 @@ class Server |
|
|
|
|
return $ticket; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getStableAccessToken() |
|
|
|
|
{ |
|
|
|
|
if (Cache::has('StableAccessToken')) { |
|
|
|
|
return Cache::get('StableAccessToken'); |
|
|
|
|
} |
|
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/stable_token'; |
|
|
|
|
$data['grant_type'] = 'client_credential'; |
|
|
|
|
$data['appid'] = self::APPID; |
|
|
|
|
$data['secret'] = self::SECRET; |
|
|
|
|
$result = $this->curlPost($url, json_encode($data), 10); |
|
|
|
|
$result = json_decode($result, true); |
|
|
|
|
if (!empty($result['access_token'])) { |
|
|
|
|
Cache::set('StableAccessToken', $result['access_token'], 6200); |
|
|
|
|
return $result['access_token']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @notes:获取令牌 |
|
|
|
|
* @return mixed|string |
|
|
|
@ -229,7 +246,7 @@ class Server |
|
|
|
|
if (Cache::has('wx_server_drafttemplatelist')) { |
|
|
|
|
//return Cache::get('wx_server_drafttemplatelist'); |
|
|
|
|
} |
|
|
|
|
$token = $this->getComponentAccessToken(); |
|
|
|
|
$token = $this->getStableAccessToken(); |
|
|
|
|
$list = []; |
|
|
|
|
if ($token) { |
|
|
|
|
$url = 'https://api.weixin.qq.com/wxa/gettemplatedraftlist?access_token=' . $token; |
|
|
|
@ -313,7 +330,7 @@ class Server |
|
|
|
|
// if (Cache::has('wx_server_templatelist')) { |
|
|
|
|
// return Cache::get('wx_server_templatelist'); |
|
|
|
|
// } |
|
|
|
|
$token = $this->getComponentAccessToken(); |
|
|
|
|
$token = $this->getStableAccessToken(); |
|
|
|
|
$list = []; |
|
|
|
|
if ($token) { |
|
|
|
|
$url = 'https://api.weixin.qq.com/wxa/gettemplatelist?access_token=' . $token; |
|
|
|
|