本文整理汇总了Java中me.chanjar.weixin.common.api.WxConsts类的典型用法代码示例。如果您正苦于以下问题:Java WxConsts类的具体用法?Java WxConsts怎么用?Java WxConsts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WxConsts类属于me.chanjar.weixin.common.api包,在下文中一共展示了WxConsts类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testSendCustomMessage
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
public void testSendCustomMessage() throws WxErrorException {
ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlCpInMemoryConfigStorage) this.wxService.configStorage;
WxCpMessage message1 = new WxCpMessage();
message1.setAgentId(configStorage.getAgentId());
message1.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
message1.setToUser(configStorage.getUserId());
message1.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
this.wxService.messageSend(message1);
WxCpMessage message2 = WxCpMessage
.TEXT()
.agentId(configStorage.getAgentId())
.toUser(configStorage.getUserId())
.content("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>")
.build();
this.wxService.messageSend(message2);
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:19,代码来源:WxCpMessageAPITest.java
示例2: testNewsReply
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
public void testNewsReply() {
WxCpMessage reply = new WxCpMessage();
reply.setToUser("OPENID");
reply.setMsgType(WxConsts.CUSTOM_MSG_NEWS);
WxArticle article1 = new WxArticle();
article1.setUrl("URL");
article1.setPicUrl("PIC_URL");
article1.setDescription("Is Really A Happy Day");
article1.setTitle("Happy Day");
reply.getArticles().add(article1);
WxArticle article2 = new WxArticle();
article2.setUrl("URL");
article2.setPicUrl("PIC_URL");
article2.setDescription("Is Really A Happy Day");
article2.setTitle("Happy Day");
reply.getArticles().add(article2);
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"news\",\"news\":{\"articles\":[{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"},{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"}]}}");
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:23,代码来源:WxCpMessageTest.java
示例3: handle
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context,
WxMpService wxMpService, WxSessionManager sessionManager) {
try {
WxMediaUploadResult wxMediaUploadResult = wxMpService.getMaterialService()
.mediaUpload(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, ClassLoader.getSystemResourceAsStream("mm.jpeg"));
WxMpXmlOutImageMessage m
= WxMpXmlOutMessage
.IMAGE()
.mediaId(wxMediaUploadResult.getMediaId())
.fromUser(wxMessage.getToUser())
.toUser(wxMessage.getFromUser())
.build();
return m;
} catch (WxErrorException e) {
e.printStackTrace();
}
return null;
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:21,代码来源:DemoImageHandler.java
示例4: testUploadMedia
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
@Test(dataProvider = "mediaFiles")
public void testUploadMedia(String mediaType, String fileType, String fileName) throws WxErrorException, IOException {
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName)) {
WxMediaUploadResult res = this.wxService.getMaterialService().mediaUpload(mediaType, fileType, inputStream);
assertNotNull(res.getType());
assertNotNull(res.getCreatedAt());
assertTrue(res.getMediaId() != null || res.getThumbMediaId() != null);
if (res.getMediaId() != null && !mediaType.equals(WxConsts.MEDIA_VIDEO)) {
//video 不支持下载,所以不加入
this.mediaIdsToDownload.add(res.getMediaId());
}
if (res.getThumbMediaId() != null) {
this.mediaIdsToDownload.add(res.getThumbMediaId());
}
System.out.println(res);
}
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:21,代码来源:WxMpMaterialServiceImplTest.java
示例5: testNewsReply
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
public void testNewsReply() {
WxMpKefuMessage reply = new WxMpKefuMessage();
reply.setToUser("OPENID");
reply.setMsgType(WxConsts.CUSTOM_MSG_NEWS);
WxArticle article1 = new WxArticle();
article1.setUrl("URL");
article1.setPicUrl("PIC_URL");
article1.setDescription("Is Really A Happy Day");
article1.setTitle("Happy Day");
reply.getArticles().add(article1);
WxArticle article2 = new WxArticle();
article2.setUrl("URL");
article2.setPicUrl("PIC_URL");
article2.setDescription("Is Really A Happy Day");
article2.setTitle("Happy Day");
reply.getArticles().add(article2);
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"news\",\"news\":{\"articles\":[{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"},{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"}]}}");
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:23,代码来源:WxMpKefuMessageTest.java
示例6: handle
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService weixinService,
WxSessionManager sessionManager) {
if (!wxMessage.getMsgType().equals(WxConsts.XML_MSG_EVENT)) {
//TODO 可以选择将消息保存到本地
}
String input = null;
if (wxMessage.getMsgType().equals(WxConsts.XML_MSG_VOICE)) {
input = wxMessage.getRecognition();
} else if (wxMessage.getMsgType().equals(WxConsts.XML_MSG_TEXT)) {
input = wxMessage.getContent();
}
// 使用用户id作为sessionId
String sessionId = wxMessage.getFromUser();
//TODO 组装回复消息
String content = kfConfiguration.router(input, sessionId, sessionManager);
return new TextBuilder().build(content, wxMessage, weixinService);
}
开发者ID:xjtushilei,项目名称:knowledge-forest-dialogue-recommendation,代码行数:24,代码来源:MsgHandler.java
示例7: handle
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService wxMpService,
WxSessionManager sessionManager) {
if (wxMessage.getMsgType().equals(WxConsts.XML_MSG_LOCATION)) {
//TODO 接收处理用户发送的地理位置消息
try {
String content = "感谢反馈,您的的地理位置已收到!";
return new TextBuilder().build(content, wxMessage, null);
} catch (Exception e) {
this.logger.error("位置消息接收处理失败", e);
return null;
}
}
//上报地理位置事件
this.logger.info("\n上报地理位置 。。。 ");
this.logger.info("\n纬度 : " + wxMessage.getLatitude());
this.logger.info("\n经度 : " + wxMessage.getLongitude());
this.logger.info("\n精度 : " + String.valueOf(wxMessage.getPrecision()));
//TODO 可以将用户地理位置信息保存到本地数据库,以便以后使用
return null;
}
开发者ID:xjtushilei,项目名称:knowledge-forest-dialogue-recommendation,代码行数:26,代码来源:LocationHandler.java
示例8: handle
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService weixinService,
WxSessionManager sessionManager) {
String msg = String.format("type:%s, event:%s, key:%s",
wxMessage.getMsgType(), wxMessage.getEvent(),
wxMessage.getEventKey());
//type是view的是链接,直接打开就行。如果想执行什么也行
if (WxConsts.BUTTON_VIEW.equals(wxMessage.getEvent())) {
return null;
}
if (wxMessage.getEventKey().equals("V1001_KF")) {
return WxMpXmlOutMessage.TEXT().content("将多源、片面、无序的碎片化知识聚合成符合人类认知学习特点的“知识森林”,缓解碎片化知识引发的学习迷航问题!\n <a href='http://yotta.xjtushilei.com:888/Yotta_frontend/index.html'>点击查看</a> /:8-) ")
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
.build();
}
if (wxMessage.getEventKey().equals("V1001_GOOD")) {
return WxMpXmlOutMessage.TEXT().content("谢谢你的点赞! /调皮")
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
.build();
}
return null;
}
开发者ID:xjtushilei,项目名称:knowledge-forest-dialogue-recommendation,代码行数:25,代码来源:MenuHandler.java
示例9: handle
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context,
WxMpService wxMpService, WxSessionManager sessionManager) {
try {
WxMediaUploadResult wxMediaUploadResult = wxMpService.getMaterialService()
.mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, ClassLoader.getSystemResourceAsStream("mm.jpeg"));
WxMpXmlOutImageMessage m
= WxMpXmlOutMessage
.IMAGE()
.mediaId(wxMediaUploadResult.getMediaId())
.fromUser(wxMessage.getToUser())
.toUser(wxMessage.getFromUser())
.build();
return m;
} catch (WxErrorException e) {
e.printStackTrace();
}
return null;
}
开发者ID:binarywang,项目名称:weixin-java-tools,代码行数:21,代码来源:DemoImageHandler.java
示例10: testUploadMedia
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
@Test(dataProvider = "mediaFiles")
public void testUploadMedia(String mediaType, String fileType, String fileName) throws WxErrorException, IOException {
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName)) {
WxMediaUploadResult res = this.wxService.getMaterialService().mediaUpload(mediaType, fileType, inputStream);
assertNotNull(res.getType());
assertNotNull(res.getCreatedAt());
assertTrue(res.getMediaId() != null || res.getThumbMediaId() != null);
if (res.getMediaId() != null && !mediaType.equals(WxConsts.MediaFileType.VIDEO)) {
//video 不支持下载,所以不加入
this.mediaIdsToDownload.add(res.getMediaId());
}
if (res.getThumbMediaId() != null) {
this.mediaIdsToDownload.add(res.getThumbMediaId());
}
System.out.println(res);
}
}
开发者ID:binarywang,项目名称:weixin-java-tools,代码行数:21,代码来源:WxMpMaterialServiceImplTest.java
示例11: testUploadMedia
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
@Test(dataProvider="mediaFiles")
public void testUploadMedia(String mediaType, String fileType, String fileName) throws WxErrorException, IOException {
InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName);
try {
WxMediaUploadResult res = this.wxService.getMaterialService().mediaUpload(mediaType, fileType, inputStream);
assertNotNull(res.getType());
assertNotNull(res.getCreatedAt());
assertTrue(res.getMediaId() != null || res.getThumbMediaId() != null);
if (res.getMediaId() != null && !mediaType.equals(WxConsts.MEDIA_VIDEO)) {
//video 不支持下载,所以不加入
this.mediaIdsToDownload.add(res.getMediaId());
}
if (res.getThumbMediaId() != null) {
this.mediaIdsToDownload.add(res.getThumbMediaId());
}
System.out.println(res);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:24,代码来源:WxMpMaterialServiceImplTest.java
示例12: testNewsReply
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
public void testNewsReply() {
WxMpKefuMessage reply = new WxMpKefuMessage();
reply.setToUser("OPENID");
reply.setMsgType(WxConsts.KefuMsgType.NEWS);
WxArticle article1 = new WxArticle();
article1.setUrl("URL");
article1.setPicUrl("PIC_URL");
article1.setDescription("Is Really A Happy Day");
article1.setTitle("Happy Day");
reply.getArticles().add(article1);
WxArticle article2 = new WxArticle();
article2.setUrl("URL");
article2.setPicUrl("PIC_URL");
article2.setDescription("Is Really A Happy Day");
article2.setTitle("Happy Day");
reply.getArticles().add(article2);
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"news\",\"news\":{\"articles\":[{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"},{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"}]}}");
}
开发者ID:binarywang,项目名称:weixin-java-tools,代码行数:23,代码来源:WxMpKefuMessageTest.java
示例13: testNewsReply
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
public void testNewsReply() {
WxMpCustomMessage reply = new WxMpCustomMessage();
reply.setToUser("OPENID");
reply.setMsgType(WxConsts.CUSTOM_MSG_NEWS);
WxArticle article1 = new WxArticle();
article1.setUrl("URL");
article1.setPicUrl("PIC_URL");
article1.setDescription("Is Really A Happy Day");
article1.setTitle("Happy Day");
reply.getArticles().add(article1);
WxArticle article2 = new WxArticle();
article2.setUrl("URL");
article2.setPicUrl("PIC_URL");
article2.setDescription("Is Really A Happy Day");
article2.setTitle("Happy Day");
reply.getArticles().add(article2);
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"news\",\"news\":{\"articles\":[{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"},{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"}]}}");
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:23,代码来源:WxMpCustomMessageTest.java
示例14: authorize
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
@GetMapping("/authorize")
public String authorize(@RequestParam("returnUrl") String returnUrl) {
//1 配置
String url = projectUrlConfig.getWechatMpAuthorize() + "/wechat/userInfo";
String redirectUrl = wxMpService.oauth2buildAuthorizationUrl(url, WxConsts.OAUTH2_SCOPE_USER_INFO, URLEncoder.encode(returnUrl));
log.info("[微信网页授权获取 code],resule={}", redirectUrl);
return "redirect:" + redirectUrl;
}
开发者ID:ldlood,项目名称:SpringBoot_Wechat_Sell,代码行数:10,代码来源:WechatController.java
示例15: qrAuthorize
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
@GetMapping("/qrauthorize")
public String qrAuthorize(@RequestParam("returnUrl") String returnUrl) {
//1 配置
String url = projectUrlConfig.getWechatOpenAuthorize() + "/wechat/qruserInfo";
String redirectUrl = wxOpenService.buildQrConnectUrl(url, WxConsts.QRCONNECT_SCOPE_SNSAPI_LOGIN, URLEncoder.encode(returnUrl));
log.info("[微信网页登陆获取 code],resule={}", redirectUrl);
return "redirect:" + redirectUrl;
}
开发者ID:ldlood,项目名称:SpringBoot_Wechat_Sell,代码行数:10,代码来源:WechatController.java
示例16: build
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
public WxCpMessage build() {
WxCpMessage m = new WxCpMessage();
m.setAgentId(this.agentId);
m.setMsgType(this.msgType);
m.setToUser(this.toUser);
m.setToParty(this.toParty);
m.setToTag(this.toTag);
m.setSafe(
(this.safe == null || "".equals(this.safe)) ? WxConsts.CUSTOM_MSG_SAFE_NO : this.safe);
return m;
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:12,代码来源:BaseBuilder.java
示例17: prepare
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
@Test(enabled = false)
public void prepare(boolean async, StringBuffer sb, WxCpMessageRouter router) {
router
.rule()
.async(async)
.msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1").content("CONTENT_1")
.handler(new WxEchoCpMessageHandler(sb, "COMBINE_4"))
.end()
.rule()
.async(async)
.msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1")
.handler(new WxEchoCpMessageHandler(sb, "COMBINE_3"))
.end()
.rule()
.async(async)
.msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK)
.handler(new WxEchoCpMessageHandler(sb, "COMBINE_2"))
.end()
.rule().async(async).msgType(WxConsts.XML_MSG_TEXT).handler(new WxEchoCpMessageHandler(sb, WxConsts.XML_MSG_TEXT)).end()
.rule().async(async).event(WxConsts.EVT_CLICK).handler(new WxEchoCpMessageHandler(sb, WxConsts.EVT_CLICK)).end()
.rule().async(async).eventKey("KEY_1").handler(new WxEchoCpMessageHandler(sb, "KEY_1")).end()
.rule().async(async).content("CONTENT_1").handler(new WxEchoCpMessageHandler(sb, "CONTENT_1")).end()
.rule().async(async).rContent(".*bc.*").handler(new WxEchoCpMessageHandler(sb, "abcd")).end()
.rule().async(async).matcher(new WxCpMessageMatcher() {
@Override
public boolean match(WxCpXmlMessage message) {
return "strangeformat".equals(message.getFormat());
}
}).handler(new WxEchoCpMessageHandler(sb, "matcher")).end()
.rule().async(async).handler(new WxEchoCpMessageHandler(sb, "ALL")).end();
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:32,代码来源:WxCpMessageRouterTest.java
示例18: uploadMedia
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
@DataProvider
public Object[][] uploadMedia() {
return new Object[][]{
new Object[]{WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, "mm.jpeg"},
new Object[]{WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, "mm.mp3"},
new Object[]{WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, "mm.mp4"},
new Object[]{WxConsts.MEDIA_FILE, WxConsts.FILE_JPG, "mm.jpeg"}
};
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:10,代码来源:WxCpMediaAPITest.java
示例19: testTextReply
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
public void testTextReply() {
WxCpMessage reply = new WxCpMessage();
reply.setToUser("OPENID");
reply.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
reply.setContent("sfsfdsdf");
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}");
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:8,代码来源:WxCpMessageTest.java
示例20: testImageReply
import me.chanjar.weixin.common.api.WxConsts; //导入依赖的package包/类
public void testImageReply() {
WxCpMessage reply = new WxCpMessage();
reply.setToUser("OPENID");
reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE);
reply.setMediaId("MEDIA_ID");
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}");
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:8,代码来源:WxCpMessageTest.java
注:本文中的me.chanjar.weixin.common.api.WxConsts类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论