|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
//缓存accessToken |
|
|
//缓存accessToken |
|
|
accessToken = object.getString("access_token"); |
|
|
accessToken = object.getString("access_token"); |
|
|
|
|
|
log.info("获取的accessToken的值:" + accessToken); |
|
|
//设置accessToken的失效时间 |
|
|
//设置accessToken的失效时间 |
|
|
Long expires_in = object.getLong("expires_in"); |
|
|
Long expires_in = object.getLong("expires_in"); |
|
|
//失效时间 = 当前时间+有效期(提前一分钟,也可以不提前) |
|
|
//失效时间 = 当前时间+有效期(提前一分钟,也可以不提前) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
responseEntity = restTemplate.postForEntity(url, param, String.class); |
|
|
responseEntity = restTemplate.postForEntity(url, param, String.class); |
|
|
String messageBody = responseEntity.getBody(); |
|
|
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); |
|
|
JSONObject jsonObject = JSON.parseObject(messageBody); |
|
|
if(Objects.nonNull(jsonObject)){ |
|
|
if(Objects.nonNull(jsonObject)){ |
|
|
log.info("openId:" + openId + "发送消息返回内容:" + jsonObject.toJSONString()); |
|
|
log.info("openId:" + openId + "发送消息返回内容:" + jsonObject.toJSONString()); |