From 01054ad480c0415de16711ab3f45926788a75c91 Mon Sep 17 00:00:00 2001 From: "jy.hu" Date: Sat, 10 May 2014 00:41:00 +0800 Subject: [PATCH] Update WeixinProxy.java fix a bug --- src/main/java/com/foxinmy/weixin4j/WeixinProxy.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/foxinmy/weixin4j/WeixinProxy.java b/src/main/java/com/foxinmy/weixin4j/WeixinProxy.java index 17a2b0b0..6a51f5d4 100644 --- a/src/main/java/com/foxinmy/weixin4j/WeixinProxy.java +++ b/src/main/java/com/foxinmy/weixin4j/WeixinProxy.java @@ -202,6 +202,8 @@ public class WeixinProxy { Calendar ca = Calendar.getInstance(); long now_time = ca.getTimeInMillis(); try { + token_path = WeixinConfig.getValue("api_token_uri"); + Response response = null; if (token_file.exists()) { token = (Token) xstream.fromXML(token_file); @@ -210,15 +212,16 @@ public class WeixinProxy { if (expise_time > now_time) { return token; } + response = request.get(token_path); } else { + response = request.get(token_path); try { token_file.createNewFile(); } catch (IOException e) { token_file.getParentFile().mkdirs(); } } - token_path = WeixinConfig.getValue("api_token_uri"); - Response response = request.get(token_path); + token = response.getAsObject(Token.class); token.setTime(now_time); token.setOpenid(appOpenId); @@ -893,7 +896,8 @@ public class WeixinProxy { * @see 删除群发 * @see {@link com.foxinmy.weixin4j.WeixinProxy#massNewsByGroup(List, String)} - * @see {@link com.foxinmy.weixin4j.WeixinProxy#massNewsByOpenIds(List, String...) + * @see {@link com.foxinmy.weixin4j.WeixinProxy#massNewsByOpenIds(List, String...) + */ public void deleteMassNews(String msgid) throws WeixinException { JSONObject obj = new JSONObject();