|
@@ -34,7 +34,7 @@ public class WxAccessTokenRemoteService {
|
|
|
.expireAfterWrite(280, TimeUnit.SECONDS)
|
|
|
.build(new CacheLoader<String, String>() {
|
|
|
@Override
|
|
|
- public String load(String s) throws Exception {
|
|
|
+ public String load(String s) {
|
|
|
return loadAccessToken(s);
|
|
|
}
|
|
|
});
|
|
@@ -48,31 +48,35 @@ public class WxAccessTokenRemoteService {
|
|
|
}
|
|
|
|
|
|
private String loadAccessToken(String gzhId) {
|
|
|
- try {
|
|
|
- Map<String, Object> param = new HashMap<>();
|
|
|
- param.put("grant_type", "client_credential");
|
|
|
- param.put("appid", gzhConfig.get(gzhId).get("appid"));
|
|
|
- param.put("secret", gzhConfig.get(gzhId).get("secret"));
|
|
|
- param.put("force_refresh", false);
|
|
|
-
|
|
|
- HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/cgi-bin/stable_token");
|
|
|
- StringEntity stringEntity = new StringEntity(JSONUtils.toJson(param), StandardCharsets.UTF_8);
|
|
|
- httpPost.setHeader("Content-Type", "application/json;charset=UTF-8");
|
|
|
- httpPost.setEntity(stringEntity);
|
|
|
- CloseableHttpResponse response = client.execute(httpPost);
|
|
|
- StatusLine statusLine = response.getStatusLine();
|
|
|
- if (statusLine.getStatusCode() == 200) {
|
|
|
- HttpEntity responseEntity = response.getEntity();
|
|
|
- if (Objects.nonNull(responseEntity)) {
|
|
|
- String responseBody = EntityUtils.toString(responseEntity, "UTF-8");
|
|
|
- Map<String, String> result = JSONUtils.fromJson(responseBody, new TypeToken<Map<String, String>>() {
|
|
|
- }, Collections.emptyMap());
|
|
|
- return result.get("access_token");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("get user error gzhId {} ", gzhId, e);
|
|
|
- }
|
|
|
- return null;
|
|
|
+ return "83_FQXl8oow9m0xNoEmb5dcYmdeas3nsJzNQP9ie_zBUqa8oILqdq0xK-_VUYEb27QqcSMSDTU8a28TfOTBTfDoZGkMEo43Aq-2gAq4qWVOcGzEQbCuEJ29bjgKpQycMLJB_fGMGAiujjD-TKfQLUXdALDOXA";
|
|
|
}
|
|
|
+
|
|
|
+// private String loadAccessToken(String gzhId) {
|
|
|
+// try {
|
|
|
+// Map<String, Object> param = new HashMap<>();
|
|
|
+// param.put("grant_type", "client_credential");
|
|
|
+// param.put("appid", gzhConfig.get(gzhId).get("appid"));
|
|
|
+// param.put("secret", gzhConfig.get(gzhId).get("secret"));
|
|
|
+// param.put("force_refresh", false);
|
|
|
+//
|
|
|
+// HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/cgi-bin/stable_token");
|
|
|
+// StringEntity stringEntity = new StringEntity(JSONUtils.toJson(param), StandardCharsets.UTF_8);
|
|
|
+// httpPost.setHeader("Content-Type", "application/json;charset=UTF-8");
|
|
|
+// httpPost.setEntity(stringEntity);
|
|
|
+// CloseableHttpResponse response = client.execute(httpPost);
|
|
|
+// StatusLine statusLine = response.getStatusLine();
|
|
|
+// if (statusLine.getStatusCode() == 200) {
|
|
|
+// HttpEntity responseEntity = response.getEntity();
|
|
|
+// if (Objects.nonNull(responseEntity)) {
|
|
|
+// String responseBody = EntityUtils.toString(responseEntity, "UTF-8");
|
|
|
+// Map<String, String> result = JSONUtils.fromJson(responseBody, new TypeToken<Map<String, String>>() {
|
|
|
+// }, Collections.emptyMap());
|
|
|
+// return result.get("access_token");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("get user error gzhId {} ", gzhId, e);
|
|
|
+// }
|
|
|
+// return null;
|
|
|
+// }
|
|
|
}
|