
org.jeewx.api.wxsendmsg.JwGetAutoReplyRuleAPI Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jeewx-api Show documentation
Show all versions of jeewx-api Show documentation
JEEWX-API(微信极速SDK、同时支持微信公众号\企业微信\支付窗\小程序\微博).
The newest version!
package org.jeewx.api.wxsendmsg;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.util.JSONUtils;
import org.jeewx.api.core.exception.WexinReqException;
import org.jeewx.api.core.req.WeiXinReqService;
import org.jeewx.api.core.req.model.message.AutoReplyRuleGet;
import org.jeewx.api.core.util.WeiXinConstant;
import org.jeewx.api.extend.CustomJsonConfig;
import org.jeewx.api.wxsendmsg.model.WxArticleConfig;
import org.jeewx.api.wxsendmsg.model.auto.AutoReplyInfoRule;
import org.jeewx.api.wxsendmsg.model.auto.KeyWordAutoReplyInfo;
import org.jeewx.api.wxsendmsg.model.auto.KeywordListInfo;
import org.jeewx.api.wxsendmsg.model.auto.ReplyListInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 获取自动回复规则
* @author luobaoli
*
*/
public class JwGetAutoReplyRuleAPI {
private static Logger logger = LoggerFactory.getLogger(JwGetAutoReplyRuleAPI.class);
/**
* 获取自动回复规则
* @param accessToken
* @return
*/
public static AutoReplyInfoRule getAutoReplyInfoRule(String accessToken) throws WexinReqException{
AutoReplyRuleGet arr = new AutoReplyRuleGet();
arr.setAccess_token(accessToken);
JSONObject result = WeiXinReqService.getInstance().doWeinxinReqJson(arr);
Object error = result.get(WeiXinConstant.RETURN_ERROR_INFO_CODE);
AutoReplyInfoRule autoReplyInfoRule = (AutoReplyInfoRule) JSONObject.toBean(result,new CustomJsonConfig(AutoReplyInfoRule.class, "keyword_autoreply_info"));
JSONObject keywordAutoReplyInfoJsonObj = result.getJSONObject("keyword_autoreply_info");
if(keywordAutoReplyInfoJsonObj!=null && !JSONUtils.isNull(keywordAutoReplyInfoJsonObj)){
/**关键词自动回复的信息 */
JSONArray keywordAutoReplyInfos = keywordAutoReplyInfoJsonObj.getJSONArray("list");
if(keywordAutoReplyInfos!=null){
List listKeyWordAutoReplyInfo = new ArrayList();
for(int i=0;i listKeywordListInfo = new ArrayList();
for(int j=0;j listReplyListInfo = new ArrayList();
for(int j=0;j listNewsInfo = new ArrayList();
for (int k = 0; k < newsInfos.size(); k++) {
WxArticleConfig wxArticleConfig = (WxArticleConfig) JSONObject.toBean(newsInfos.getJSONObject(k), WxArticleConfig.class);
listNewsInfo.add(wxArticleConfig);
}
replyListInfo.setNews_info(listNewsInfo);
}
listReplyListInfo.add(replyListInfo);
}
keyWordAutoReplyInfo.setReply_list_info(listReplyListInfo);
}
listKeyWordAutoReplyInfo.add(keyWordAutoReplyInfo);
}
autoReplyInfoRule.setKeyword_autoreply_info(listKeyWordAutoReplyInfo);
}
}
return autoReplyInfoRule;
}
public static void main(String[] args) {
try {
//String s = JwTokenAPI.getAccessToken("wx298c4cc7312063df","fbf8cebf983c931bd7c1bee1498f8605");
String s = "chsqpXVzXmPgqgZrrZnQzxqEi2L-1qStuVDOeZ-hKlY-Gkdlca3Q2HE9__BXc5hNoU1Plpc56UyZ1QoaDMkRbVSi0iUUVb27GTMaTDBfmuY";
JwGetAutoReplyRuleAPI.getAutoReplyInfoRule(s);
} catch (WexinReqException e) {
e.printStackTrace();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy