This commit is contained in:
2025-03-08 15:46:24 +08:00
parent 50927481d2
commit c2ebbd71e2
35 changed files with 303 additions and 314 deletions

@ -30,7 +30,7 @@ public class WxMpUtil {
String response = HttpUtil.get(url);
JSONObject jsonObject = JSONObject.parseObject(response);
ACCESS_TOKEN = jsonObject.getString("access_token");
expireTime = new Date(System.currentTimeMillis() + jsonObject.getInteger("expires_in") * 1000);
expireTime = new Date(System.currentTimeMillis() + jsonObject.getInteger("expires_in") * 1000 / 2);
return ACCESS_TOKEN;
}
@ -47,6 +47,10 @@ public class WxMpUtil {
httpPost.setHeader("Content-Type", "application/json");
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
if (response.getStatusLine().getStatusCode() != 200) {
expireTime = new Date();
throw new Exception("获取小程序码失败");
}
HttpEntity responseEntity = response.getEntity();
if (responseEntity != null) {
byte[] bytes = EntityUtils.toByteArray(responseEntity);