-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
MP_主动发送消息(客服消息)
Binary Wang edited this page Dec 2, 2016
·
4 revisions
更多用例,请参考me.chanjar.weixin.mp.api.impl.WxMpKefuServiceImplTest
WxMpKefuMessage message = ...;
// 设置消息的内容等信息
wxMpService.getKefuService().sendKefuMessage(message);
不同类型的客服消息有不同的构造方法:
WxMpKefuMessage
.TEXT()
.toUser("OPENID")
.content("sfsfdsdf")
.build();
WxMpKefuMessage
.IMAGE()
.toUser("OPENID")
.mediaId("MEDIA_ID")
.build();
WxMpKefuMessage.VOICE()
.toUser("OPENID")
.mediaId("MEDIA_ID")
.build();
WxMpKefuMessage.VIDEO()
.toUser("OPENID")
.title("TITLE")
.mediaId("MEDIA_ID")
.thumbMediaId("MEDIA_ID")
.description("DESCRIPTION")
.build();
WxMpKefuMessage.MUSIC()
.toUser("OPENID")
.title("TITLE")
.thumbMediaId("MEDIA_ID")
.description("DESCRIPTION")
.musicUrl("MUSIC_URL")
.hqMusicUrl("HQ_MUSIC_URL")
.build();
WxMpKefuMessage.WxArticle article1 = new WxMpKefuMessage.WxArticle();
article1.setUrl("URL");
article1.setPicUrl("PIC_URL");
article1.setDescription("Is Really A Happy Day");
article1.setTitle("Happy Day");
WxMpKefuMessage.WxArticle article2 = new WxMpKefuMessage.WxArticle();
article2.setUrl("URL");
article2.setPicUrl("PIC_URL");
article2.setDescription("Is Really A Happy Day");
article2.setTitle("Happy Day");
WxMpKefuMessage.NEWS()
.toUser("OPENID")
.addArticle(article1)
.addArticle(article2)
.build();