Ver Fonte

微信媒资:小程序Toke更新 优化

ZHAOXIAN há 8 meses atrás
pai
commit
90d7f2ebda

+ 3 - 2
job-adq/src/main/java/cn/com/ctop/job/adq/data/service/impl/AppletTokenRefreshServiceImpl.java

@@ -44,11 +44,12 @@ public class AppletTokenRefreshServiceImpl implements IAppletTokenRefreshService
             param.put("appid", appId);
             param.put("secret", applet.getString("appSecret"));
             param.put("grant_type", "client_credential");
-            String result = HttpUtils.httpGet("https://api.weixin.qq.com/cgi-bin/token", param, null);
+//            String result = HttpUtils.httpGet("https://api.weixin.qq.com/cgi-bin/token", param, null);
+            String result = HttpUtils.httpPostRequest("https://api.weixin.qq.com/cgi-bin/stable_token", param, null);
             JSONObject tokenInfo = JSONObject.parseObject(result);
             if (!Check.isNull(tokenInfo)) {
                 String accessToken = tokenInfo.getString("access_token");
-                redis2Template_db5.opsForValue().set("wechat-applet-access-token-key-" + applet.getInteger("id"), accessToken, 60, TimeUnit.MINUTES);
+                redis2Template_db5.opsForValue().set("wechat-applet-access-token-key-" + applet.getInteger("id"), accessToken, tokenInfo.getInteger("expires_in"), TimeUnit.SECONDS);
                 applet.put("token", accessToken);
                 log.info("小程序:{},更新token完成", name);
             } else {