diff --git a/src/main/java/com/foxinmy/weixin4j/WeixinProxy.java b/src/main/java/com/foxinmy/weixin4j/WeixinProxy.java index 6a51f5d4..79b1db03 100644 --- a/src/main/java/com/foxinmy/weixin4j/WeixinProxy.java +++ b/src/main/java/com/foxinmy/weixin4j/WeixinProxy.java @@ -29,6 +29,7 @@ import com.foxinmy.weixin4j.exception.WeixinException; import com.foxinmy.weixin4j.http.HttpRequest; import com.foxinmy.weixin4j.http.Response; import com.foxinmy.weixin4j.model.Button; +import com.foxinmy.weixin4j.model.CustomRecord; import com.foxinmy.weixin4j.model.Following; import com.foxinmy.weixin4j.model.Group; import com.foxinmy.weixin4j.model.MpArticle; @@ -71,9 +72,8 @@ public class WeixinProxy { * 随机数 * @param signature * 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数 - * @return - * 开发者通过检验signature对请求进行相关校验。若确认此次GET请求来自微信服务器,请原样返回echostr参数内容,则接入生效 - * ,成为开发者成功,否则接入失败 + * @return 开发者通过检验signature对请求进行相关校验。若确认此次GET请求来自微信服务器 + * 请原样返回echostr参数内容,则接入生效 成为开发者成功,否则接入失败 * @see 接入指南 */ @@ -91,7 +91,7 @@ public class WeixinProxy { } String _signature = null; try { - String[] a = { app_token, timestamp, nonce }; + String[] a = {app_token, timestamp, nonce}; Arrays.sort(a); StringBuilder sb = new StringBuilder(3); for (String str : a) { @@ -203,7 +203,7 @@ public class WeixinProxy { long now_time = ca.getTimeInMillis(); try { token_path = WeixinConfig.getValue("api_token_uri"); - Response response = null; + Response response = request.get(token_path); if (token_file.exists()) { token = (Token) xstream.fromXML(token_file); @@ -221,7 +221,6 @@ public class WeixinProxy { token_file.getParentFile().mkdirs(); } } - token = response.getAsObject(Token.class); token.setTime(now_time); token.setOpenid(appOpenId); @@ -557,8 +556,7 @@ public class WeixinProxy { } catch (UnsupportedEncodingException e) { e.printStackTrace(); } - JSONObject obj = response.getAsJson(); - return JSON.parseObject(obj.getString("group"), Group.class); + return response.getAsJson().getObject("group", Group.class); } /** @@ -575,8 +573,9 @@ public class WeixinProxy { Token token = getToken(); Response response = request.get(String.format(group_get_uri, token.getAccess_token())); - JSONObject obj = response.getAsJson(); - return JSON.parseArray(obj.getString("groups"), Group.class); + + return JSON.parseArray(response.getAsJson().getString("groups"), + Group.class); } /** @@ -887,7 +886,7 @@ public class WeixinProxy { /** * 删除群发消息 *
- * 请注意,只有已经发送成功的消息才能删除删除消息只是将消息的图文详情页失效,已经收到的用户,还是能在其本地看到消息卡片 + * 请注意,只有已经发送成功的消息才能删除删除消息只是将消息的图文详情页失效,已经收到的用户,还是能在其本地看到消息卡片 *
* * @param msgid @@ -896,8 +895,7 @@ 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(); @@ -913,4 +911,46 @@ public class WeixinProxy { e.printStackTrace(); } } + + /** + * 客服聊天记录 + * + * @param openId + * 用户标识 可为空 + * @param starttime + * 查询开始时间 + * @param endtime + * 查询结束时间 每次查询不能跨日查询 + * @param pagesize + * 每页大小 每页最多拉取1000条 + * @param pageindex + * 查询第几页 从1开始 + * @throws WeixinException + * @see com.foxinmy.weixin4j.model.CustomRecord + * @see 查询客服聊天记录 + */ + public List