浏览代码

将wxToken 调整新的url redis缓存时间1800s

hxd 1 月之前
父节点
当前提交
f7fe9ae088

+ 2 - 2
portal-service-domain/src/main/java/com/hfln/portal/domain/customer/util/WxOfficeAccountClient.java

@@ -116,7 +116,7 @@ public class WxOfficeAccountClient {
             return cachedToken;
         }
         //2.如果Redis中没有,则调用微信接口获取
-        String url = "https://api.weixin.qq.com/cgi-bin/token" +
+        String url = "https://api.weixin.qq.com/cgi-bin/stable_token" +
                 "?grant_type=client_credential" +
                 "&appid=" + appId +
                 "&secret=" + secret;
@@ -137,7 +137,7 @@ public class WxOfficeAccountClient {
                     String accessToken = (String) map.get("access_token");
 
                     //4.写入redis,有效期7080秒
-                    stringRedisTemplate.opsForValue().set(ACCESS_TOKEN_KEY, accessToken, 7080, TimeUnit.SECONDS);
+                    stringRedisTemplate.opsForValue().set(ACCESS_TOKEN_KEY, accessToken, 1800, TimeUnit.SECONDS);
                     log.info("从微信中获取 access_token 并写入Redis:{}", accessToken);
                     return accessToken;
                 } else {