Browse Source

增加微信发送消息请求接口信息

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
cbd45b9322
1 changed files with 7 additions and 0 deletions
  1. +7
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WxServiceImpl.java

+ 7
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WxServiceImpl.java View File

@@ -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());

Loading…
Cancel
Save