当前位置: 首页>>代码示例>>Java>>正文


Java WxMpService类代码示例

本文整理汇总了Java中me.chanjar.weixin.mp.api.WxMpService的典型用法代码示例。如果您正苦于以下问题:Java WxMpService类的具体用法?Java WxMpService怎么用?Java WxMpService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WxMpService类属于me.chanjar.weixin.mp.api包,在下文中一共展示了WxMpService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例2: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例3: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例4: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例5: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例6: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例7: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例8: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例9: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例10: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例11: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例12: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例13: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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

示例14: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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:11590692,项目名称:Wechat-Group,代码行数:16,代码来源:DemoGuessNumberHandler.java

示例15: handle

import me.chanjar.weixin.mp.api.WxMpService; //导入依赖的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:11590692,项目名称:Wechat-Group,代码行数:9,代码来源:DemoTextHandler.java


注:本文中的me.chanjar.weixin.mp.api.WxMpService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。