本文整理汇总了Java中me.chanjar.weixin.mp.api.WxMpMessageHandler类的典型用法代码示例。如果您正苦于以下问题:Java WxMpMessageHandler类的具体用法?Java WxMpMessageHandler怎么用?Java WxMpMessageHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WxMpMessageHandler类属于me.chanjar.weixin.mp.api包,在下文中一共展示了WxMpMessageHandler类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: text
import me.chanjar.weixin.mp.api.WxMpMessageHandler; //导入依赖的package包/类
/**
* @param wxMpMessageRouter 微信路由
* @param async
* @param ask
* @param answer
*/
public static void text(
WxMpMessageRouter wxMpMessageRouter,
boolean async,
String ask,
String answer
) {
WxMpMessageHandler handler = (wxMessage, context, wxMpService, sessionManager) -> {
WxMpXmlOutTextMessage m
= WxMpXmlOutMessage
.TEXT()
.content(answer)
.fromUser(wxMessage.getToUserName())
.toUser(wxMessage.getFromUserName())
.build();
return m;
};
wxMpMessageRouter
.rule()
.async(async)
.content(ask)
.handler(handler)
.end();
}
开发者ID:cyzaoj,项目名称:mywx,代码行数:30,代码来源:WxMpUtil.java
示例2: initWeixin
import me.chanjar.weixin.mp.api.WxMpMessageHandler; //导入依赖的package包/类
private static void initWeixin() {
try (InputStream is1 = ClassLoader
.getSystemResourceAsStream("test-config.xml")) {
WxMpDemoInMemoryConfigStorage config = WxMpDemoInMemoryConfigStorage
.fromXml(is1);
wxMpConfigStorage = config;
wxMpService = new WxMpServiceImpl();
wxMpService.setWxMpConfigStorage(config);
WxMpMessageHandler logHandler = new DemoLogHandler();
WxMpMessageHandler textHandler = new DemoTextHandler();
WxMpMessageHandler imageHandler = new DemoImageHandler();
WxMpMessageHandler oauth2handler = new DemoOAuth2Handler();
DemoGuessNumberHandler guessNumberHandler = new DemoGuessNumberHandler();
wxMpMessageRouter = new WxMpMessageRouter(wxMpService);
wxMpMessageRouter.rule().handler(logHandler).next().rule()
.msgType(WxConsts.XML_MSG_TEXT).matcher(guessNumberHandler)
.handler(guessNumberHandler).end().rule().async(false).content("哈哈")
.handler(textHandler).end().rule().async(false).content("图片")
.handler(imageHandler).end().rule().async(false).content("oauth")
.handler(oauth2handler).end();
} catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:11590692,项目名称:Wechat-Group,代码行数:28,代码来源:WxMpDemoServer.java
示例3: initWeixin
import me.chanjar.weixin.mp.api.WxMpMessageHandler; //导入依赖的package包/类
private static void initWeixin() {
try (InputStream is1 = ClassLoader
.getSystemResourceAsStream("test-config.xml")) {
WxMpDemoInMemoryConfigStorage config = WxMpDemoInMemoryConfigStorage
.fromXml(is1);
wxMpConfigStorage = config;
wxMpService = new WxMpServiceApacheHttpClientImpl();
wxMpService.setWxMpConfigStorage(config);
WxMpMessageHandler logHandler = new DemoLogHandler();
WxMpMessageHandler textHandler = new DemoTextHandler();
WxMpMessageHandler imageHandler = new DemoImageHandler();
WxMpMessageHandler oauth2handler = new DemoOAuth2Handler();
DemoGuessNumberHandler guessNumberHandler = new DemoGuessNumberHandler();
wxMpMessageRouter = new WxMpMessageRouter(wxMpService);
wxMpMessageRouter.rule().handler(logHandler).next().rule()
.msgType(WxConsts.XmlMsgType.TEXT).matcher(guessNumberHandler)
.handler(guessNumberHandler).end().rule().async(false).content("哈哈")
.handler(textHandler).end().rule().async(false).content("图片")
.handler(imageHandler).end().rule().async(false).content("oauth")
.handler(oauth2handler).end();
} catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:binarywang,项目名称:weixin-java-tools,代码行数:28,代码来源:WxMpDemoServer.java
示例4: initWeixin
import me.chanjar.weixin.mp.api.WxMpMessageHandler; //导入依赖的package包/类
private static void initWeixin() {
InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml");
try {
WxMpDemoInMemoryConfigStorage config = WxMpDemoInMemoryConfigStorage
.fromXml(is1);
wxMpConfigStorage = config;
wxMpService = new WxMpServiceImpl();
wxMpService.setWxMpConfigStorage(config);
WxMpMessageHandler logHandler = new DemoLogHandler();
WxMpMessageHandler textHandler = new DemoTextHandler();
WxMpMessageHandler imageHandler = new DemoImageHandler();
WxMpMessageHandler oauth2handler = new DemoOAuth2Handler();
DemoGuessNumberHandler guessNumberHandler = new DemoGuessNumberHandler();
wxMpMessageRouter = new WxMpMessageRouter(wxMpService);
wxMpMessageRouter.rule().handler(logHandler).next().rule()
.msgType(WxConsts.XML_MSG_TEXT).matcher(guessNumberHandler)
.handler(guessNumberHandler).end().rule().async(false).content("哈哈")
.handler(textHandler).end().rule().async(false).content("图片")
.handler(imageHandler).end().rule().async(false).content("oauth")
.handler(oauth2handler).end();
} finally {
IOUtils.closeQuietly(is1);
}
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:28,代码来源:WxMpDemoServer.java
注:本文中的me.chanjar.weixin.mp.api.WxMpMessageHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论