wang hou sheng 8 months ago
parent c7fc36d584
commit e4f8e5b709
  1. 10
      app/common/library/wxserver/Server.php

@ -66,8 +66,8 @@ class Server
*/ */
public function getComponentAccessToken() public function getComponentAccessToken()
{ {
if (Cache::has('ComponentAccessToken')) { if (Cache::has('wxserver_component_access_token')) {
return Cache::get('ComponentAccessToken'); return Cache::get('wxserver_component_access_token');
} }
$url = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token'; $url = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token';
$ticket = Cache::get('component_verify_ticket'); $ticket = Cache::get('component_verify_ticket');
@ -79,7 +79,7 @@ class Server
$result = $this->curlPost($url, json_encode($data), 10); $result = $this->curlPost($url, json_encode($data), 10);
$result = json_decode($result, true); $result = json_decode($result, true);
if (!empty($result['component_access_token'])) { if (!empty($result['component_access_token'])) {
Cache::set('ComponentAccessToken', $result['component_access_token'], 6200); Cache::set('wxserver_component_access_token', $result['component_access_token'], 6200);
return $result['component_access_token']; return $result['component_access_token'];
} }
} }
@ -324,9 +324,9 @@ class Server
public function getTemplatelist(): array public function getTemplatelist(): array
{ {
if (Cache::has('wx_server_templatelist')) { if (Cache::has('wx_server_templatelist')) {
return Cache::get('wx_server_templatelist'); //return Cache::get('wx_server_templatelist');
} }
$token = $this->getStableAccessToken(); $token = $this->getComponentAccessToken();
$list = []; $list = [];
if ($token) { if ($token) {
$url = 'https://api.weixin.qq.com/wxa/gettemplatelist?access_token=' . $token . '&template_type=1'; $url = 'https://api.weixin.qq.com/wxa/gettemplatelist?access_token=' . $token . '&template_type=1';

Loading…
Cancel
Save