Commit f0df92ff3f1f899b107e8197895077eff764ff18
1 parent
0941c9c456
Exists in
master
access_token-获取时间差BUG
Showing 3 changed files with 6 additions and 7 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/AccessTokenServlet.java
View file @
f0df92f
| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * 获取到access_token |
| 16 | - * 每1小时59获取一次token,保证长期有效。 | |
| 16 | + * 每1小时获取一次token,保证长期有效。 | |
| 17 | 17 | * (微信公众号规定2小时token失效,每天只能获取2000次。) |
| 18 | 18 | */ |
| 19 | 19 | @Component |
| ... | ... | @@ -33,7 +33,7 @@ |
| 33 | 33 | try{ |
| 34 | 34 | accessToken = this.getToken(); |
| 35 | 35 | if(null!=accessToken){ |
| 36 | - Thread.sleep(1000 * 7000); //获取到access_token 休眠7000秒 | |
| 36 | + Thread.sleep(1000 * 3600); //获取到access_token 休眠3600秒 | |
| 37 | 37 | }else{ |
| 38 | 38 | Thread.sleep(1000 * 3); //获取的access_token为空 休眠3秒 |
| 39 | 39 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushArticleTask.java
View file @
f0df92f
| ... | ... | @@ -127,7 +127,7 @@ |
| 127 | 127 | map.put("keyword2",new DataEntity(lymsPushMessage.getHname(),"#173177")); |
| 128 | 128 | map.put("keyword3",new DataEntity(lymsPushMessage.getDname(),"#173177")); |
| 129 | 129 | map.put("remark",new DataEntity("预祝您早日康复","#173177")); |
| 130 | - Integer code= WeiXinUtil.SendWeChatMsg(token,lymsPushMessage.getGzopenid(), Constant.GZ_TEMPLATE_ID,map); | |
| 130 | + Integer code= WeiXinUtil.SendWeChatMsg(lymsPushMessage.getGzopenid(), Constant.GZ_TEMPLATE_ID,map); | |
| 131 | 131 | if(null==code||code!=0){ |
| 132 | 132 | //更新到LymsPushMessages记录 |
| 133 | 133 | lymsPushMessage.setState(2);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) |
| ... | ... | @@ -160,7 +160,7 @@ |
| 160 | 160 | map.put("keyword2",new DataEntity(lymsPushMessage.getHname(),"#173177")); |
| 161 | 161 | map.put("keyword3",new DataEntity(lymsPushMessage.getDname(),"#173177")); |
| 162 | 162 | map.put("remark",new DataEntity("预祝您早日康复","#173177")); |
| 163 | - Integer code= WeiXinUtil.SendWeChatMsg(token,lymsPushMessage.getGzopenid(),Constant.GZ_TEMPLATE_ID,map); | |
| 163 | + Integer code= WeiXinUtil.SendWeChatMsg(lymsPushMessage.getGzopenid(),Constant.GZ_TEMPLATE_ID,map); | |
| 164 | 164 | if(null==code||code!=0){ |
| 165 | 165 | //更新到LymsPushMessages记录 |
| 166 | 166 | lymsPushMessage.setState(2);//推送状态:0待推送 1成功 2失败。(在备注写失败原因) |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/WeiXinUtil.java
View file @
f0df92f
| ... | ... | @@ -60,14 +60,13 @@ |
| 60 | 60 | /*** |
| 61 | 61 | * 发送消息 |
| 62 | 62 | * |
| 63 | - * @param token | |
| 64 | 63 | * @param openid 关注公众号的微信id |
| 65 | 64 | * @param template_id 公众号消息模板id |
| 66 | 65 | * @param dataMap 推送内容消息主题显示相关map |
| 67 | 66 | */ |
| 68 | - public static Integer SendWeChatMsg(String token, String openid, String template_id, Map<String,Object> dataMap) { | |
| 67 | + public static Integer SendWeChatMsg(String openid, String template_id, Map<String,Object> dataMap) { | |
| 69 | 68 | // 接口地址 |
| 70 | - String sendMsgApi = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+token; | |
| 69 | + String sendMsgApi = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+AccessTokenServlet.accessToken; | |
| 71 | 70 | //整体参数map |
| 72 | 71 | Map<String, Object> paramMap = new HashMap<String, Object>(); |
| 73 | 72 | paramMap.put("touser", openid); |