Update WeixinProxy.java

fix a bug
This commit is contained in:
jy.hu 2014-05-10 00:41:00 +08:00
parent 611a204b8f
commit 01054ad480

View File

@ -202,6 +202,8 @@ public class WeixinProxy {
Calendar ca = Calendar.getInstance(); Calendar ca = Calendar.getInstance();
long now_time = ca.getTimeInMillis(); long now_time = ca.getTimeInMillis();
try { try {
token_path = WeixinConfig.getValue("api_token_uri");
Response response = null;
if (token_file.exists()) { if (token_file.exists()) {
token = (Token) xstream.fromXML(token_file); token = (Token) xstream.fromXML(token_file);
@ -210,15 +212,16 @@ public class WeixinProxy {
if (expise_time > now_time) { if (expise_time > now_time) {
return token; return token;
} }
response = request.get(token_path);
} else { } else {
response = request.get(token_path);
try { try {
token_file.createNewFile(); token_file.createNewFile();
} catch (IOException e) { } catch (IOException e) {
token_file.getParentFile().mkdirs(); token_file.getParentFile().mkdirs();
} }
} }
token_path = WeixinConfig.getValue("api_token_uri");
Response response = request.get(token_path);
token = response.getAsObject(Token.class); token = response.getAsObject(Token.class);
token.setTime(now_time); token.setTime(now_time);
token.setOpenid(appOpenId); token.setOpenid(appOpenId);
@ -894,6 +897,7 @@ public class WeixinProxy {
* href="http://mp.weixin.qq.com/wiki/index.php?title=%E9%AB%98%E7%BA%A7%E7%BE%A4%E5%8F%91%E6%8E%A5%E5%8F%A3#.E5.88.A0.E9.99.A4.E7.BE.A4.E5.8F.91">删除群发</a> * href="http://mp.weixin.qq.com/wiki/index.php?title=%E9%AB%98%E7%BA%A7%E7%BE%A4%E5%8F%91%E6%8E%A5%E5%8F%A3#.E5.88.A0.E9.99.A4.E7.BE.A4.E5.8F.91">删除群发</a>
* @see {@link com.foxinmy.weixin4j.WeixinProxy#massNewsByGroup(List, String)} * @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 { public void deleteMassNews(String msgid) throws WeixinException {
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();