|
|
@@ -129,6 +129,7 @@ public class WxServiceImpl implements IWxService { |
|
|
|
} |
|
|
|
//缓存accessToken |
|
|
|
accessToken = object.getString("access_token"); |
|
|
|
log.info("获取的accessToken的值:" + accessToken); |
|
|
|
//设置accessToken的失效时间 |
|
|
|
Long expires_in = object.getLong("expires_in"); |
|
|
|
//失效时间 = 当前时间+有效期(提前一分钟,也可以不提前) |
|
|
@@ -177,6 +178,12 @@ public class WxServiceImpl implements IWxService { |
|
|
|
|
|
|
|
responseEntity = restTemplate.postForEntity(url, param, String.class); |
|
|
|
String messageBody = responseEntity.getBody(); |
|
|
|
Integer errcode = JSONObject.parseObject(messageBody).getInteger("errcode").intValue(); |
|
|
|
if(errcode != null && errcode != 0){ |
|
|
|
String errmsg = JSONObject.parseObject(messageBody).getString("errmsg"); |
|
|
|
log.info("请求accessToken失败,返回码:" + errcode.intValue() + "错误信息:" + errmsg); |
|
|
|
return JsonResult.error(errcode.intValue(),errmsg); |
|
|
|
} |
|
|
|
JSONObject jsonObject = JSON.parseObject(messageBody); |
|
|
|
if(Objects.nonNull(jsonObject)){ |
|
|
|
log.info("openId:" + openId + "发送消息返回内容:" + jsonObject.toJSONString()); |