Browse Source

update wechat New client default get token from cache

ls 1 year ago
parent
commit
e34377bb9d
1 changed files with 4 additions and 3 deletions
  1. 4 3
      client.go

+ 4 - 3
client.go

@@ -17,7 +17,7 @@ func NewClient(appID, appSecret, token, encodingAESKey string) *Client {
 	if v, ok := cache.Load(key); ok {
 		return v.(*Client)
 	}
-	c := &Client{AppID: appID, AppSecret: appSecret, Token: token, EncodingAESKey: encodingAESKey}
+	c := &Client{AppID: appID, AppSecret: appSecret, Token: token, EncodingAESKey: encodingAESKey, UseCacheToken: true}
 	cache.Store(key, c)
 	return c
 }
@@ -288,8 +288,9 @@ func (wc Client) CreateMenu(menu FormMenu) (err error) {
 }
 
 // GetSignPackage JS 签名
-//   uri      当前 URL
-//   nonceStr 随机字符串
+//
+//	uri      当前 URL
+//	nonceStr 随机字符串
 func (wc Client) GetSignPackage(uri, nonceStr string) (sign SignPackage, err error) {
 	if wc.AccessToken, err = wc.getToken(); err != nil {
 		return