
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 weixin4j Show documentation
Show all versions of weixin4j Show documentation
微信和钉钉开发SDK,主要提供微信、企业微信、钉钉的JAVA封装,降低集成难度,让API变简单
The newest version!
package org.jeewx.api.wxsendmsg;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
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.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;
import java.util.ArrayList;
import java.util.List;
/**
* 获取自动回复规则
* @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.toJavaObject(result,new CustomJsonConfig(AutoReplyInfoRule.class, "keyword_autoreply_info"));
SimplePropertyPreFilter keywordFilter = new SimplePropertyPreFilter();
keywordFilter.getExcludes().add("keyword_autoreply_info");
AutoReplyInfoRule autoReplyInfoRule = JSONObject.parseObject(JSONObject.toJSONString(result, keywordFilter), AutoReplyInfoRule.class);
JSONObject keywordAutoReplyInfoJsonObj = result.getJSONObject("keyword_autoreply_info");
if(keywordAutoReplyInfoJsonObj!=null && !keywordAutoReplyInfoJsonObj.isEmpty()){
/**关键词自动回复的信息 */
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.toJavaObject(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