mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
小程序增加素材类型常量
This commit is contained in:
parent
fd5b077e56
commit
9eb4ccf4a4
@ -8,6 +8,13 @@ package cn.binarywang.wx.miniapp.constant;
|
|||||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
*/
|
*/
|
||||||
public class WxMaConstants {
|
public class WxMaConstants {
|
||||||
|
/**
|
||||||
|
* 素材类型
|
||||||
|
*/
|
||||||
|
public static class MediaType {
|
||||||
|
public static final String IMAGE = "image";//图片
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息格式
|
* 消息格式
|
||||||
*/
|
*/
|
||||||
|
@ -6,6 +6,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaMessage;
|
|||||||
import cn.binarywang.wx.miniapp.bean.WxMaKefuMessage;
|
import cn.binarywang.wx.miniapp.bean.WxMaKefuMessage;
|
||||||
import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage;
|
import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage;
|
||||||
import cn.binarywang.wx.miniapp.config.WxMaConfig;
|
import cn.binarywang.wx.miniapp.config.WxMaConfig;
|
||||||
|
import cn.binarywang.wx.miniapp.constant.WxMaConstants;
|
||||||
import cn.binarywang.wx.miniapp.message.WxMaMessageHandler;
|
import cn.binarywang.wx.miniapp.message.WxMaMessageHandler;
|
||||||
import cn.binarywang.wx.miniapp.message.WxMaMessageRouter;
|
import cn.binarywang.wx.miniapp.message.WxMaMessageRouter;
|
||||||
import cn.binarywang.wx.miniapp.test.TestConfig;
|
import cn.binarywang.wx.miniapp.test.TestConfig;
|
||||||
@ -37,6 +38,7 @@ public class WxMaDemoServer {
|
|||||||
.toUser(wxMessage.getFromUser()).build());
|
.toUser(wxMessage.getFromUser()).build());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final WxMaMessageHandler textHandler = new WxMaMessageHandler() {
|
private static final WxMaMessageHandler textHandler = new WxMaMessageHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(WxMaMessage wxMessage, Map<String, Object> context,
|
public void handle(WxMaMessage wxMessage, Map<String, Object> context,
|
||||||
@ -47,13 +49,14 @@ public class WxMaDemoServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final WxMaMessageHandler picHandler = new WxMaMessageHandler() {
|
private static final WxMaMessageHandler picHandler = new WxMaMessageHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(WxMaMessage wxMessage, Map<String, Object> context,
|
public void handle(WxMaMessage wxMessage, Map<String, Object> context,
|
||||||
WxMaService service, WxSessionManager sessionManager) throws WxErrorException {
|
WxMaService service, WxSessionManager sessionManager) throws WxErrorException {
|
||||||
try {
|
try {
|
||||||
WxMediaUploadResult uploadResult = service.getMediaService()
|
WxMediaUploadResult uploadResult = service.getMediaService()
|
||||||
.uploadMedia("image", "png",
|
.uploadMedia(WxMaConstants.MediaType.IMAGE, "png",
|
||||||
ClassLoader.getSystemResourceAsStream("tmp.png"));
|
ClassLoader.getSystemResourceAsStream("tmp.png"));
|
||||||
service.getMsgService().sendKefuMsg(
|
service.getMsgService().sendKefuMsg(
|
||||||
WxMaKefuMessage
|
WxMaKefuMessage
|
||||||
@ -66,13 +69,14 @@ public class WxMaDemoServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final WxMaMessageHandler qrcodeHandler = new WxMaMessageHandler() {
|
private static final WxMaMessageHandler qrcodeHandler = new WxMaMessageHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(WxMaMessage wxMessage, Map<String, Object> context,
|
public void handle(WxMaMessage wxMessage, Map<String, Object> context,
|
||||||
WxMaService service, WxSessionManager sessionManager) throws WxErrorException {
|
WxMaService service, WxSessionManager sessionManager) throws WxErrorException {
|
||||||
try {
|
try {
|
||||||
final File file = service.getQrcodeService().createQrcode("123", 430);
|
final File file = service.getQrcodeService().createQrcode("123", 430);
|
||||||
WxMediaUploadResult uploadResult = service.getMediaService().uploadMedia("image", file);
|
WxMediaUploadResult uploadResult = service.getMediaService().uploadMedia(WxMaConstants.MediaType.IMAGE, file);
|
||||||
service.getMsgService().sendKefuMsg(
|
service.getMsgService().sendKefuMsg(
|
||||||
WxMaKefuMessage
|
WxMaKefuMessage
|
||||||
.IMAGE()
|
.IMAGE()
|
||||||
|
Loading…
Reference in New Issue
Block a user