Skip to content

Commit

Permalink
#193 添加客服消息类型 mpnews,miniprogrampage,msgmenu
Browse files Browse the repository at this point in the history
添加客服输入状态接口 MessageAPI.messageCustomTyping
  • Loading branch information
liyi committed Feb 22, 2019
1 parent c654872 commit c642552
Show file tree
Hide file tree
Showing 11 changed files with 270 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ weixin-popular 已支持的微信平台
<dependency>
<groupId>com.github.liyiorg</groupId>
<artifactId>weixin-popular</artifactId>
<version>2.8.26-SNAPSHOT</version>
<version>2.8.26</version>
</dependency>
```
* [升级注意事项](https://github.com/liyiorg/weixin-popular/wiki/jar_update)
Expand Down
4 changes: 3 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ WEIXIN-POPULAR CHANGELOG
===========================
https://github.com/liyiorg/weixin-popular

Changes in version 2.8.26 (2019-02-?)
Changes in version 2.8.26 (2019-02-22)
-------------------------------------
* #186 添加多次分账接口,添加分账完结接口
* #193 添加客服消息类型 mpnews,miniprogrampage,msgmenu
* 添加客服输入状态接口 MessageAPI.messageCustomTyping

Changes in version 2.8.25 (2018-12-18)
-------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.github.liyiorg</groupId>
<artifactId>weixin-popular</artifactId>
<version>2.8.26-SNAPSHOT</version>
<version>2.8.26</version>

<name>weixin-popular</name>
<description>The weixin-popular is a JAVA SDK for weixin. Weixin web url is https://mp.weixin.qq.com.</description>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/weixin/popular/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public interface Version {

String VERSION = "2.8.26-SNAPSHOT";
String VERSION = "2.8.26";
}
21 changes: 21 additions & 0 deletions src/main/java/weixin/popular/api/MessageAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ public static BaseResult messageCustomSend(String access_token, Message message)
String str = JsonUtil.toJSONString(message);
return messageCustomSend(access_token, str);
}

/**
* 客服输入状态
* @since 2.8.26
* @param access_token access_token
* @param touser touser
* @param command <br>
* "Typing":对用户下发“正在输入"状态 <br>
* "CancelTyping":取消对用户的”正在输入"状态
* @return BaseResult
*/
public static BaseResult messageCustomTyping(String access_token, String touser, String command) {
String json = String.format("{\"touser\":\"%s\",\"command\":\"%s\"}", touser, command);
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(jsonHeader)
.setUri(BASE_URI + "/cgi-bin/message/custom/typing")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.setEntity(new StringEntity(json, Charset.forName("utf-8")))
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest, BaseResult.class);
}

/**
* 高级群发 构成 MassMPnewsMessage 对象的前置请求接口
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/weixin/popular/bean/message/message/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ protected Message(String touser,String msgtype) {
}


private Customservice customservice; //如果需要以某个客服帐号来发消息(在微信6.0.2及以上版本中显示自定义头像),则需在JSON数据包的后半部分加入customservice参数,例如发送文本消息则改为:

private String touser;

private String msgtype;

private Customservice customservice; //如果需要以某个客服帐号来发消息(在微信6.0.2及以上版本中显示自定义头像),则需在JSON数据包的后半部分加入customservice参数,例如发送文本消息则改为:

public String getTouser() {
return touser;
}
Expand All @@ -35,27 +35,27 @@ protected void setMsgtype(String msgtype) {
this.msgtype = msgtype;
}

public Customservice getCustomservice() {
return customservice;
}

public void setCustomservice(Customservice customservice) {
this.customservice = customservice;
}

public static class Customservice{

private String kf_account;

public String getKf_account() {
return kf_account;
}

public void setKf_account(String kf_account) {
this.kf_account = kf_account;
}

}

public Customservice getCustomservice() {
return customservice;
}

public void setCustomservice(Customservice customservice) {
this.customservice = customservice;
}



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package weixin.popular.bean.message.message;

/**
* 小程序卡片
*
* @serial 2.8.26
* @author LiYi
*
*/
public class MiniprogrampageMessage extends Message {

public MiniprogrampageMessage() {
}

public MiniprogrampageMessage(String touser) {
super(touser, "miniprogrampage");
}

public MiniprogrampageMessage(String touser, Miniprogrampage miniprogrampage) {
this(touser);
this.miniprogrampage = miniprogrampage;
}

private Miniprogrampage miniprogrampage;

public Miniprogrampage getMiniprogrampage() {
return miniprogrampage;
}

public void setMiniprogrampage(Miniprogrampage miniprogrampage) {
this.miniprogrampage = miniprogrampage;
}

public static class Miniprogrampage {

private String title;
private String pagepath;
private String thumb_media_id;
private String appid;

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getPagepath() {
return pagepath;
}

public void setPagepath(String pagepath) {
this.pagepath = pagepath;
}

public String getThumb_media_id() {
return thumb_media_id;
}

public void setThumb_media_id(String thumb_media_id) {
this.thumb_media_id = thumb_media_id;
}

public String getAppid() {
return appid;
}

public void setAppid(String appid) {
this.appid = appid;
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package weixin.popular.bean.message.message;

/**
*
* 发送图文消息(点击跳转到图文消息页面)
*
* @since 2.8.26
* @author LiYi
*/
public class MpnewsMessage extends Message {

public MpnewsMessage() {
}

public MpnewsMessage(String toUser, String mediaId) {
super(toUser, "mpnews");
this.mpnews = new Mpnews();
this.mpnews.setMedia_id(mediaId);
}

private Mpnews mpnews;

public Mpnews getMpnews() {
return mpnews;
}

public void setMpnews(Mpnews mpnews) {
this.mpnews = mpnews;
}

public static class Mpnews {
private String media_id;

public String getMedia_id() {
return media_id;
}

public void setMedia_id(String mediaId) {
media_id = mediaId;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package weixin.popular.bean.message.message;

import java.util.List;

/**
* 菜单消息
*
* @since 2.8.26
* @author LiYi
*/
public class MsgmenuMessage extends Message {

public MsgmenuMessage() {
}

public MsgmenuMessage(String touser, Msgmenu msgmenu) {
super(touser, "msgmenu");
this.msgmenu = msgmenu;
}

private Msgmenu msgmenu;

public Msgmenu getMsgmenu() {
return msgmenu;
}

public void setMsgmenu(Msgmenu msgmenu) {
this.msgmenu = msgmenu;
}

public static class Msgmenu {

private String head_content;

private String tail_content;

private List<MenuOption> list;

public String getHead_content() {
return head_content;
}

public void setHead_content(String head_content) {
this.head_content = head_content;
}

public String getTail_content() {
return tail_content;
}

public void setTail_content(String tail_content) {
this.tail_content = tail_content;
}

public List<MenuOption> getList() {
return list;
}

public void setList(List<MenuOption> list) {
this.list = list;
}

}

public static class MenuOption {
private String id;
private String content;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

}
}
16 changes: 14 additions & 2 deletions src/main/java/weixin/popular/bean/message/message/NewsMessage.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package weixin.popular.bean.message.message;

import java.util.Collections;
import java.util.List;

/**
* 图文消息
* 图文消息条数限制在10条以内,注意,如果图文数超过10,则将会无响应
* 发送图文消息(点击跳转到外链)<br>
* 图文消息条数限制在1条以内,注意,如果图文数超过1,则将会返回错误码45008
*
* @author LiYi
*/
Expand All @@ -18,6 +19,17 @@ public NewsMessage(String touser, List<Article> articles) {
this.news = new News();
this.news.setArticles(articles);
}

/**
* @since 2.8.26
* @param touser
* @param article
*/
public NewsMessage(String touser, Article article) {
super(touser, "news");
this.news = new News();
this.news.setArticles(Collections.singletonList(article));
}

private News news;

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/weixin/popular/bean/xmlmessage/XMLNewsMessage.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package weixin.popular.bean.xmlmessage;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import weixin.popular.bean.message.message.Message;
Expand All @@ -24,6 +25,20 @@ public XMLNewsMessage(String toUserName, String fromUserName, List<Article> arti
super(toUserName, fromUserName, "news");
this.articles = articles;
}

/**
* @since 2.8.26
* @param toUserName
* toUserName
* @param fromUserName
* fromUserName
* @param article
* article
*/
public XMLNewsMessage(String toUserName, String fromUserName, Article article) {
super(toUserName, fromUserName, "news");
this.articles = Collections.singletonList(article);
}

@Override
public String subXML() {
Expand Down

0 comments on commit c642552

Please sign in to comment.