本文整理汇总了Java中me.chanjar.weixin.mp.bean.WxMpXmlOutMessage类的典型用法代码示例。如果您正苦于以下问题:Java WxMpXmlOutMessage类的具体用法?Java WxMpXmlOutMessage怎么用?Java WxMpXmlOutMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WxMpXmlOutMessage类属于me.chanjar.weixin.mp.bean包,在下文中一共展示了WxMpXmlOutMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handle
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context,
WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
String eventKey = wxMessage.getEventKey(); // qrscene_quancheng-ec
String companyId = eventKey;
LOGGER.info("company id: " + companyId);
WxMpUser user = wxMpService.getUserService().userInfo(wxMessage.getFromUserName(), "zh_CN");
String content = "Hi " + user.getNickname() + ", 还差一步<a href=\"#?user=" + user.getOpenId() + "&company="
+ companyId + "\">完善个人信息</a> 就可以开始申请购票了";
WxMpXmlOutTextMessage m = WxMpXmlOutTextMessage.TEXT().content(content)
.fromUser(wxMessage.getToUserName()).toUser(wxMessage.getFromUserName()).build();
LOGGER.error("outMessage" + m.toXml());
return m;
}
开发者ID:jihao,项目名称:weixin-server-demo,代码行数:18,代码来源:SubscribeHandler.java
示例2: handle
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context,
WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
LOGGER.info("wxMpService==null ? " + (wxMpService == null));
WxMpUser user = wxMpService.getUserService().userInfo(wxMessage.getFromUserName(), "zh_CN");
// 后台逻辑,获得此用户的公司id,这里是 hard code
String companyId = "quancheng-ec";
WxMpQrCodeTicket ticket = wxMpService.getQrcodeService().qrCodeCreateLastTicket(companyId);
// "gQFF8DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL3Ewd2Y5U2JscUMtUlJ2OVFjMlFMAAIEez6pVwMEAAAAAA==";
String qrCodePictureUrl = wxMpService.getQrcodeService().qrCodePictureUrl(ticket.getTicket());
LOGGER.info("qrCodePictureUrl: " + qrCodePictureUrl);
WxMpXmlOutNewsMessage.Item item = new WxMpXmlOutNewsMessage.Item();
item.setDescription(user.getNickname() + " 邀请您加入公司:" + companyId);
item.setPicUrl(qrCodePictureUrl);
item.setTitle("邀请加入");
item.setUrl(qrCodePictureUrl);
WxMpXmlOutNewsMessage m = WxMpXmlOutMessage.NEWS().fromUser(wxMessage.getToUserName())
.toUser(wxMessage.getFromUserName()).addArticle(item).build();
LOGGER.error("outMessage=" + m.toXml());
return m;
}
开发者ID:jihao,项目名称:weixin-server-demo,代码行数:25,代码来源:InviteHandler.java
示例3: handle
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService,
WxSessionManager sessionManager) throws WxErrorException {
LOGGER.info(wxMessage.toString());
String echoMessage = "voide2text: " + wxMessage.getRecognition();
LOGGER.info(echoMessage);
TextUnderstander mTextUnderstander = TextUnderstander.createTextUnderstander(); // 开始语义理解
mTextUnderstander.setParameter(SpeechConstant.LANGUAGE, "zh_cn");
TextUnderstanderListener searchListener = new CustomTextUnderstanderListener(wxMessage, context, wxMpService,
sessionManager, this.xfyun_appid, this.flight_search_url, this.flight_user_token);
mTextUnderstander.understandText(wxMessage.getRecognition(), searchListener); // 初始化监听器
return null;
}
开发者ID:jihao,项目名称:weixin-server-demo,代码行数:17,代码来源:VoiceHandler.java
示例4: doPost
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.POST)
public String doPost(@RequestBody String xml) {
WxMpXmlMessage message = WxMpXmlMessage.fromXml(xml);
switch (message.getMsgType()) {
default:
WxMpXmlOutNewsMessage m = WxMpXmlOutMessage.NEWS().fromUser(message.getToUserName()).toUser(message.getFromUserName()).build();
Page<Article> articles = articleService.get(0, 4);
for (Article article : articles) {
WxMpXmlOutNewsMessage.Item item = new WxMpXmlOutNewsMessage.Item();
item.setDescription(article.getTitle());
if (article.getImage() == null) item.setPicUrl("http://www.lixiaocong.com/image/logo.png");
else item.setPicUrl(article.getImage());
item.setTitle(article.getTitle());
item.setUrl("http://www.lixiaocong.com/blog/detail?id=" + article.getId());
m.addArticle(item);
}
return m.toXml();
}
}
开发者ID:lixiaocong,项目名称:lxcCMS,代码行数:21,代码来源:WeixinController.java
示例5: handle
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
TextBuilder out = WxMpXmlOutMessage.TEXT().fromUser(wxMessage.getToUserName()).toUser(wxMessage.getFromUserName());
try {
Operator op = TableOperator.get(wxMessage.getFromUserName());
if (op == null) {
out.content(lang("Not_Operator"));
// } else if (op.getAccess() >= Access.NO_LOGIN) {
// out.content(lang("No_Login"));
} else {
out.content(format("Operator_Info", op.getId(), op.getName(), op.getAccess(), op.getBlock(), op.getWeek()));
}
} catch (Exception e) {
e.printStackTrace();
out.content(lang("Login_Error"));
}
return out.build();
}
开发者ID:ZSCNetSupportDept,项目名称:WechatTicketSystem,代码行数:19,代码来源:OperatorInfoHandler.java
示例6: handle
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
TextBuilder out = WxMpXmlOutMessage.TEXT().fromUser(wxMessage.getToUserName()).toUser(wxMessage.getFromUserName());
try {
Operator operator = TableOperator.get(wxMessage.getFromUserName());
if (operator == null)
out.content(lang("Not_Operator"));
else if (operator.getAccess() >= Access.NO_LOGIN) {
out.content(lang("No_Login"));
} else {
WxSession session = WechatSession.create();
session.setAttribute(Attribute.AUTHORIZED, Command.LOGIN);
session.setAttribute(Attribute.WECHAT, wxMessage.getFromUserName());
session.setAttribute(Attribute.OPERATOR, operator);
out.content(format("Home_Page_Msg", format("Operator_Home_Page", session.getId())));
}
} catch (Exception e) {
e.printStackTrace();
out.content(lang("Login_Error"));
}
return out.build();
}
开发者ID:ZSCNetSupportDept,项目名称:WechatTicketSystem,代码行数:23,代码来源:LoginHandler.java
示例7: handle
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
User u = TableUser.getByWechat(wxMessage.getFromUserName());
Ticket t = TableTicket.latest(u);
if (t == null) {
return WxMpXmlOutMessage.TEXT().fromUser(wxMessage.getToUserName()).toUser(wxMessage.getFromUserName())
.content(lang("No_Ticket_Available")).build();
}
WxSession session = WechatSession.create();
session.setAttribute(Attribute.AUTHORIZED, Command.QUERY);
session.setAttribute(Attribute.WECHAT, wxMessage.getFromUserName());
session.setAttribute(Attribute.USER, u);
NewsBuilder out = WxMpXmlOutMessage.NEWS().fromUser(wxMessage.getToUserName()).toUser(wxMessage.getFromUserName());
WxMpXmlOutNewsMessage.Item item = new WxMpXmlOutNewsMessage.Item();
item.setTitle(lang("Query_Title"));
item.setDescription(ParseUtil.parseTicket(t) + "\n" + lang("More_Details"));
item.setUrl(format("User_Query_Link", session.getId()));
out.addArticle(item);
return out.build();
}
开发者ID:ZSCNetSupportDept,项目名称:WechatTicketSystem,代码行数:22,代码来源:QueryHandler.java
示例8: handle
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
User u = TableUser.getByWechat(wxMessage.getFromUserName());
if (TableTicket.hasOpen(u)) {
return WxMpXmlOutMessage.TEXT().fromUser(wxMessage.getToUserName()).toUser(wxMessage.getFromUserName())
.content(lang("Already_Opening_Ticket")).build();
}
WxSession session = WechatSession.create();
session.setAttribute(Attribute.AUTHORIZED, Command.SUBMIT);
session.setAttribute(Attribute.WECHAT, wxMessage.getFromUserName());
session.setAttribute(Attribute.USER, u);
NewsBuilder out = WxMpXmlOutMessage.NEWS().fromUser(wxMessage.getToUserName()).toUser(wxMessage.getFromUserName());
WxMpXmlOutNewsMessage.Item item = new WxMpXmlOutNewsMessage.Item();
item.setTitle(lang("Submit_Title"));
item.setDescription(lang("Submit_Desc"));
item.setUrl(format("User_Submit_Link", session.getId(), u.getName(), u.getIsp().id, u.getRoom(), u.getBlock(), u.getPhone()));
out.addArticle(item);
return out.build();
}
开发者ID:ZSCNetSupportDept,项目名称:WechatTicketSystem,代码行数:21,代码来源:SubmitHandler.java
示例9: handle
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
// String msg = source.getMessage("message.welcome", null, Locale.getDefault());
String event = StringUtils.isBlank(wxMessage.getEvent()) ? StringUtils.EMPTY : wxMessage.getEvent();
WxMpXmlOutTextMessage m = null;
if (WxConsts.EVT_SUBSCRIBE.equals(event)) {
m
= WxMpXmlOutMessage
.TEXT()
.content("message.welcome")
.fromUser(wxMessage.getToUserName())
.toUser(wxMessage.getFromUserName())
.build();
} else if (WxConsts.EVT_UNSUBSCRIBE.equals(event)) {
}
log.info("{} ---> {}", event, ToStringBuilder.reflectionToString(wxMessage));
return m;
}
开发者ID:cyzaoj,项目名称:mywx,代码行数:19,代码来源:FocusMeMessage.java
示例10: text
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的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
示例11: processRequest
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
/**
* 微信服务器POST过来的数据
*
* @return
* @throws IOException
*/
@RequestMapping(value = "/connect", method = { RequestMethod.POST }, produces = { MediaType.APPLICATION_XML_VALUE })
@ResponseBody
public String processRequest(HttpServletRequest request, @RequestParam String nonce, @RequestParam String timestamp,
@RequestParam(defaultValue = "raw") String encrypt_type) throws IOException {
WxMpXmlMessage inMessage = null;
if ("raw".equals(encrypt_type)) {
// 明文传输的消息
inMessage = WxMpXmlMessage.fromXml(request.getInputStream());
} else if ("aes".equals(encrypt_type)) {
// 是aes加密的消息
String msgSignature = request.getParameter("msg_signature");
inMessage = WxMpXmlMessage.fromEncryptedXml(request.getInputStream(), wxMpConfigStorage, timestamp, nonce,
msgSignature);
} else {
return "<response>不可识别的加密类型</response>";
}
WxMpXmlOutMessage outMessage = wxMpMessageRouter.route(inMessage);
if (outMessage != null) {
if ("raw".equals(encrypt_type)) {
return outMessage.toXml();
} else if ("aes".equals(encrypt_type)) {
return outMessage.toEncryptedXml(wxMpConfigStorage);
}
} else {
return "";
}
return "<response>服务号不可用</response>";
}
开发者ID:jihao,项目名称:weixin-server-demo,代码行数:39,代码来源:WeiXinController.java
示例12: handle
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService,
WxSessionManager sessionManager) throws WxErrorException {
String echoMessage = "echo: " + wxMessage.getContent();
LOGGER.info(echoMessage);
// 创建文本语义理解对象
TextUnderstander mTextUnderstander = TextUnderstander.createTextUnderstander(); // 开始语义理解
mTextUnderstander.setParameter(SpeechConstant.LANGUAGE, "zh_cn");
TextUnderstanderListener searchListener = new CustomTextUnderstanderListener(wxMessage, context, wxMpService, sessionManager, this.xfyun_appid, this.flight_search_url, this.flight_user_token);
mTextUnderstander.understandText(wxMessage.getContent(), searchListener ); // 初始化监听器
return null;
}
开发者ID:jihao,项目名称:weixin-server-demo,代码行数:16,代码来源:DefaultHandler.java
示例13: service
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
/**
* 处理微信推送过来的消息
*
* @param wxMessage
* @return true 代表继续执行别的router,false 代表停止执行别的router
*/
protected WxMpXmlOutMessage service(WxMpXmlMessage wxMessage,
WxMpService wxMpService,
WxSessionManager sessionManager,
WxErrorExceptionHandler exceptionHandler) {
try {
Map<String, Object> context = new HashMap<String, Object>();
// 如果拦截器不通过
for (WxMpMessageInterceptor interceptor : this.interceptors) {
if (!interceptor.intercept(wxMessage, context, wxMpService, sessionManager)) {
return null;
}
}
// 交给handler处理
WxMpXmlOutMessage res = null;
for (WxMpMessageHandler handler : this.handlers) {
// 返回最后handler的结果
if(handler == null){
continue;
}
res = handler.handle(wxMessage, context, wxMpService, sessionManager);
}
return res;
} catch (WxErrorException e) {
exceptionHandler.handle(e);
}
return null;
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:38,代码来源:WxMpMessageRouterRule.java
示例14: config_WxMpXmlOutNewsMessage
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
private static XStream config_WxMpXmlOutNewsMessage() {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(WxMpXmlOutMessage.class);
xstream.processAnnotations(WxMpXmlOutNewsMessage.class);
xstream.processAnnotations(WxMpXmlOutNewsMessage.Item.class);
return xstream;
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:8,代码来源:XStreamTransformer.java
示例15: config_WxMpXmlOutMusicMessage
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
private static XStream config_WxMpXmlOutMusicMessage() {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(WxMpXmlOutMessage.class);
xstream.processAnnotations(WxMpXmlOutMusicMessage.class);
xstream.processAnnotations(WxMpXmlOutMusicMessage.Music.class);
return xstream;
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:8,代码来源:XStreamTransformer.java
示例16: config_WxMpXmlOutVideoMessage
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
private static XStream config_WxMpXmlOutVideoMessage() {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(WxMpXmlOutMessage.class);
xstream.processAnnotations(WxMpXmlOutVideoMessage.class);
xstream.processAnnotations(WxMpXmlOutVideoMessage.Video.class);
return xstream;
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:8,代码来源:XStreamTransformer.java
示例17: config_WxMpXmlOutTransferCustomerServiceMessage
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
private static XStream config_WxMpXmlOutTransferCustomerServiceMessage() {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(WxMpXmlOutMessage.class);
xstream.processAnnotations(WxMpXmlOutTransferCustomerServiceMessage.class);
xstream.processAnnotations(WxMpXmlOutTransferCustomerServiceMessage.TransInfo.class);
return xstream;
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:8,代码来源:XStreamTransformer.java
示例18: handle
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService,
WxSessionManager sessionManager) throws WxErrorException {
if (isUserWantGuess(wxMessage)) {
letsGo(wxMessage, wxMpService, sessionManager);
}
if (isUserAnswering(wxMessage)) {
giveHint(wxMessage, wxMpService, sessionManager);
}
return null;
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:16,代码来源:DemoGuessNumberHandler.java
示例19: handle
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context,
WxMpService wxMpService, WxSessionManager sessionManager) {
WxMpXmlOutTextMessage m
= WxMpXmlOutMessage.TEXT().content("测试加密消息").fromUser(wxMessage.getToUser())
.toUser(wxMessage.getFromUser()).build();
return m;
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:9,代码来源:DemoTextHandler.java
示例20: handle
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; //导入依赖的package包/类
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService wxMpService,
WxSessionManager sessionManager) {
String href = "<a href=\"" + wxMpService.oauth2buildAuthorizationUrl(
wxMpService.getWxMpConfigStorage().getOauth2redirectUri(),
WxConsts.OAUTH2_SCOPE_USER_INFO, null) + "\">测试oauth2</a>";
return WxMpXmlOutMessage.TEXT().content(href)
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
.build();
}
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:12,代码来源:DemoOAuth2Handler.java
注:本文中的me.chanjar.weixin.mp.bean.WxMpXmlOutMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论