mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-02-18 14:16:25 +08:00
#68 实现获取公众号的自动回复规则的接口
This commit is contained in:
@@ -77,6 +77,11 @@ public interface WxMpService {
|
||||
*/
|
||||
String CONNECT_OAUTH2_AUTHORIZE_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s#wechat_redirect";
|
||||
|
||||
/**
|
||||
* 获取公众号的自动回复规则
|
||||
*/
|
||||
String GET_CURRENT_AUTOREPLY_INFO_URL = "https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info";
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 验证消息的确来自微信服务器
|
||||
@@ -273,6 +278,24 @@ public interface WxMpService {
|
||||
*/
|
||||
String[] getCallbackIP() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 获取公众号的自动回复规则
|
||||
* http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751299&token=&lang=zh_CN
|
||||
* 开发者可以通过该接口,获取公众号当前使用的自动回复规则,包括关注后自动回复、消息自动回复(60分钟内触发一次)、关键词自动回复。
|
||||
* 请注意:
|
||||
* 1、第三方平台开发者可以通过本接口,在旗下公众号将业务授权给你后,立即通过本接口检测公众号的自动回复配置,并通过接口再次给公众号设置好自动回复规则,以提升公众号运营者的业务体验。
|
||||
* 2、本接口仅能获取公众号在公众平台官网的自动回复功能中设置的自动回复规则,若公众号自行开发实现自动回复,或通过第三方平台开发者来实现,则无法获取。
|
||||
* 3、认证/未认证的服务号/订阅号,以及接口测试号,均拥有该接口权限。
|
||||
* 4、从第三方平台的公众号登录授权机制上来说,该接口从属于消息与菜单权限集。
|
||||
* 5、本接口中返回的图片/语音/视频为临时素材(临时素材每次获取都不同,3天内有效,通过素材管理-获取临时素材接口来获取这些素材),本接口返回的图文消息为永久素材素材(通过素材管理-获取永久素材接口来获取这些素材)。
|
||||
* 接口调用请求说明
|
||||
* http请求方式: GET(请使用https协议)
|
||||
* https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info?access_token=ACCESS_TOKEN
|
||||
* </pre>
|
||||
*/
|
||||
WxMpCurrentAutoReplyInfo getCurrentAutoReplyInfo() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求
|
||||
*/
|
||||
@@ -292,15 +315,10 @@ public interface WxMpService {
|
||||
*/
|
||||
<T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取代理对象
|
||||
*/
|
||||
//HttpHost getRequestHttpProxy();
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试
|
||||
* 默认:1000ms
|
||||
* @param retrySleepMillis 默认:1000ms
|
||||
* </pre>
|
||||
*/
|
||||
void setRetrySleepMillis(int retrySleepMillis);
|
||||
|
||||
@@ -231,6 +231,11 @@ public abstract class AbstractWxMpServiceImpl<H, P> implements WxMpService, Requ
|
||||
return ipArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpCurrentAutoReplyInfo getCurrentAutoReplyInfo() throws WxErrorException {
|
||||
return WxMpCurrentAutoReplyInfo.fromJson(this.get(GET_CURRENT_AUTOREPLY_INFO_URL, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String url, String queryParam) throws WxErrorException {
|
||||
return execute(SimpleGetRequestExecutor.create(this), url, queryParam);
|
||||
|
||||
@@ -0,0 +1,359 @@
|
||||
package me.chanjar.weixin.mp.bean.result;
|
||||
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import me.chanjar.weixin.common.util.ToStringUtils;
|
||||
import me.chanjar.weixin.common.util.json.WxBooleanTypeAdapter;
|
||||
import me.chanjar.weixin.common.util.json.WxDateTypeAdapter;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 公众号的自动回复规则
|
||||
* Created by Binary Wang on 2017-7-8.
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* </pre>
|
||||
*/
|
||||
public class WxMpCurrentAutoReplyInfo {
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringUtils.toSimpleString(this);
|
||||
}
|
||||
|
||||
public static WxMpCurrentAutoReplyInfo fromJson(String json) {
|
||||
return WxMpGsonBuilder.create().fromJson(json, WxMpCurrentAutoReplyInfo.class);
|
||||
}
|
||||
|
||||
@SerializedName("is_add_friend_reply_open")
|
||||
@JsonAdapter(WxBooleanTypeAdapter.class)
|
||||
private Boolean isAddFriendReplyOpen;
|
||||
|
||||
@SerializedName("is_autoreply_open")
|
||||
@JsonAdapter(WxBooleanTypeAdapter.class)
|
||||
private Boolean isAutoReplyOpen;
|
||||
|
||||
@SerializedName("add_friend_autoreply_info")
|
||||
private AutoReplyInfo addFriendAutoReplyInfo;
|
||||
|
||||
@SerializedName("message_default_autoreply_info")
|
||||
private AutoReplyInfo messageDefaultAutoReplyInfo;
|
||||
|
||||
@SerializedName("keyword_autoreply_info")
|
||||
private KeywordAutoReplyInfo keywordAutoReplyInfo;
|
||||
|
||||
public Boolean getAddFriendReplyOpen() {
|
||||
return this.isAddFriendReplyOpen;
|
||||
}
|
||||
|
||||
public void setAddFriendReplyOpen(Boolean addFriendReplyOpen) {
|
||||
isAddFriendReplyOpen = addFriendReplyOpen;
|
||||
}
|
||||
|
||||
public Boolean getAutoReplyOpen() {
|
||||
return this.isAutoReplyOpen;
|
||||
}
|
||||
|
||||
public void setAutoReplyOpen(Boolean autoReplyOpen) {
|
||||
isAutoReplyOpen = autoReplyOpen;
|
||||
}
|
||||
|
||||
public AutoReplyInfo getAddFriendAutoReplyInfo() {
|
||||
return this.addFriendAutoReplyInfo;
|
||||
}
|
||||
|
||||
public void setAddFriendAutoReplyInfo(AutoReplyInfo addFriendAutoReplyInfo) {
|
||||
this.addFriendAutoReplyInfo = addFriendAutoReplyInfo;
|
||||
}
|
||||
|
||||
public AutoReplyInfo getMessageDefaultAutoReplyInfo() {
|
||||
return this.messageDefaultAutoReplyInfo;
|
||||
}
|
||||
|
||||
public void setMessageDefaultAutoReplyInfo(AutoReplyInfo messageDefaultAutoReplyInfo) {
|
||||
this.messageDefaultAutoReplyInfo = messageDefaultAutoReplyInfo;
|
||||
}
|
||||
|
||||
public KeywordAutoReplyInfo getKeywordAutoReplyInfo() {
|
||||
return this.keywordAutoReplyInfo;
|
||||
}
|
||||
|
||||
public void setKeywordAutoReplyInfo(KeywordAutoReplyInfo keywordAutoReplyInfo) {
|
||||
this.keywordAutoReplyInfo = keywordAutoReplyInfo;
|
||||
}
|
||||
|
||||
public static class AutoReplyRule {
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringUtils.toSimpleString(this);
|
||||
}
|
||||
|
||||
@SerializedName("rule_name")
|
||||
private String ruleName;
|
||||
|
||||
@SerializedName("create_time")
|
||||
@JsonAdapter(WxDateTypeAdapter.class)
|
||||
private Date createTime;
|
||||
|
||||
@SerializedName("reply_mode")
|
||||
private String replyMode;
|
||||
|
||||
@SerializedName("keyword_list_info")
|
||||
private List<KeywordInfo> keywordListInfo;
|
||||
|
||||
@SerializedName("reply_list_info")
|
||||
private List<ReplyInfo> replyListInfo;
|
||||
|
||||
public String getRuleName() {
|
||||
return this.ruleName;
|
||||
}
|
||||
|
||||
public void setRuleName(String ruleName) {
|
||||
this.ruleName = ruleName;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getReplyMode() {
|
||||
return this.replyMode;
|
||||
}
|
||||
|
||||
public void setReplyMode(String replyMode) {
|
||||
this.replyMode = replyMode;
|
||||
}
|
||||
|
||||
public List<KeywordInfo> getKeywordListInfo() {
|
||||
return this.keywordListInfo;
|
||||
}
|
||||
|
||||
public void setKeywordListInfo(List<KeywordInfo> keywordListInfo) {
|
||||
this.keywordListInfo = keywordListInfo;
|
||||
}
|
||||
|
||||
public List<ReplyInfo> getReplyListInfo() {
|
||||
return this.replyListInfo;
|
||||
}
|
||||
|
||||
public void setReplyListInfo(List<ReplyInfo> replyListInfo) {
|
||||
this.replyListInfo = replyListInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ReplyInfo {
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringUtils.toSimpleString(this);
|
||||
}
|
||||
|
||||
private String type;
|
||||
private String content;
|
||||
|
||||
@SerializedName("news_info")
|
||||
private NewsInfo newsInfo;
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public NewsInfo getNewsInfo() {
|
||||
return this.newsInfo;
|
||||
}
|
||||
|
||||
public void setNewsInfo(NewsInfo newsInfo) {
|
||||
this.newsInfo = newsInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public static class NewsInfo {
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringUtils.toSimpleString(this);
|
||||
}
|
||||
|
||||
private List<NewsItem> list;
|
||||
|
||||
public List<NewsItem> getList() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
public void setList(List<NewsItem> list) {
|
||||
this.list = list;
|
||||
}
|
||||
}
|
||||
|
||||
public static class NewsItem {
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringUtils.toSimpleString(this);
|
||||
}
|
||||
|
||||
@SerializedName("cover_url")
|
||||
private String coverUrl;
|
||||
private String author;
|
||||
@SerializedName("content_url")
|
||||
private String contentUrl;
|
||||
private String digest;
|
||||
@SerializedName("show_cover")
|
||||
@JsonAdapter(WxBooleanTypeAdapter.class)
|
||||
private Boolean showCover;
|
||||
@SerializedName("source_url")
|
||||
private String sourceUrl;
|
||||
private String title;
|
||||
|
||||
public String getCoverUrl() {
|
||||
return this.coverUrl;
|
||||
}
|
||||
|
||||
public void setCoverUrl(String coverUrl) {
|
||||
this.coverUrl = coverUrl;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return this.author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getContentUrl() {
|
||||
return this.contentUrl;
|
||||
}
|
||||
|
||||
public void setContentUrl(String contentUrl) {
|
||||
this.contentUrl = contentUrl;
|
||||
}
|
||||
|
||||
public String getDigest() {
|
||||
return this.digest;
|
||||
}
|
||||
|
||||
public void setDigest(String digest) {
|
||||
this.digest = digest;
|
||||
}
|
||||
|
||||
public Boolean getShowCover() {
|
||||
return this.showCover;
|
||||
}
|
||||
|
||||
public void setShowCover(Boolean showCover) {
|
||||
this.showCover = showCover;
|
||||
}
|
||||
|
||||
public String getSourceUrl() {
|
||||
return this.sourceUrl;
|
||||
}
|
||||
|
||||
public void setSourceUrl(String sourceUrl) {
|
||||
this.sourceUrl = sourceUrl;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
|
||||
public static class KeywordInfo {
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringUtils.toSimpleString(this);
|
||||
}
|
||||
|
||||
private String type;
|
||||
@SerializedName("match_mode")
|
||||
private String matchMode;
|
||||
private String content;
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMatchMode() {
|
||||
return this.matchMode;
|
||||
}
|
||||
|
||||
public void setMatchMode(String matchMode) {
|
||||
this.matchMode = matchMode;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
||||
public static class KeywordAutoReplyInfo {
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringUtils.toSimpleString(this);
|
||||
}
|
||||
|
||||
private List<AutoReplyRule> list;
|
||||
|
||||
public List<AutoReplyRule> getList() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
public void setList(List<AutoReplyRule> list) {
|
||||
this.list = list;
|
||||
}
|
||||
}
|
||||
|
||||
public static class AutoReplyInfo {
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringUtils.toSimpleString(this);
|
||||
}
|
||||
|
||||
private String type;
|
||||
private String content;
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user