cn.binarywang.wx.miniapp.bean.WxMaKefuMessage Java Examples

The following examples show how to use cn.binarywang.wx.miniapp.bean.WxMaKefuMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WxMaDemoServer.java    From weixin-java-tools with Apache License 2.0 6 votes vote down vote up
@Override
public void handle(WxMaMessage wxMessage, Map<String, Object> context,
                   WxMaService service, WxSessionManager sessionManager) throws WxErrorException {
  try {
    WxMediaUploadResult uploadResult = service.getMediaService()
      .uploadMedia(WxMaConstants.MediaType.IMAGE, "png",
        ClassLoader.getSystemResourceAsStream("tmp.png"));
    service.getMsgService().sendKefuMsg(
      WxMaKefuMessage
        .newImageBuilder()
        .mediaId(uploadResult.getMediaId())
        .toUser(wxMessage.getFromUser())
        .build());
  } catch (WxErrorException e) {
    e.printStackTrace();
  }
}
 
Example #2
Source File: WxMaDemoServer.java    From weixin-java-tools with Apache License 2.0 6 votes vote down vote up
@Override
public void handle(WxMaMessage wxMessage, Map<String, Object> context,
                   WxMaService service, WxSessionManager sessionManager) throws WxErrorException {
  try {
    final File file = service.getQrcodeService().createQrcode("123", 430);
    WxMediaUploadResult uploadResult = service.getMediaService().uploadMedia(WxMaConstants.MediaType.IMAGE, file);
    service.getMsgService().sendKefuMsg(
      WxMaKefuMessage
        .newImageBuilder()
        .mediaId(uploadResult.getMediaId())
        .toUser(wxMessage.getFromUser())
        .build());
  } catch (WxErrorException e) {
    e.printStackTrace();
  }
}
 
Example #3
Source File: MaPageMessageBuilder.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
@Override
public WxMaKefuMessage build() {
  WxMaKefuMessage m = super.build();
  m.setMaPage(WxMaKefuMessage.KfMaPage.builder()
    .title(this.title)
    .pagePath(this.pagePath)
    .thumbMediaId(this.thumbMediaId)
    .build()
  );
  return m;
}
 
Example #4
Source File: LinkMessageBuilder.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
@Override
public WxMaKefuMessage build() {
  WxMaKefuMessage m = super.build();
  m.setLink(WxMaKefuMessage.KfLink.builder().title(this.title)
    .description(this.description)
    .url(this.url)
    .thumbUrl(this.thumbUrl)
    .build()
  );
  return m;
}
 
Example #5
Source File: BaseBuilder.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
/**
 * 构造器方法.
 */
public WxMaKefuMessage build() {
  WxMaKefuMessage m = new WxMaKefuMessage();
  m.setMsgType(this.msgType);
  m.setToUser(this.toUser);
  return m;
}
 
Example #6
Source File: WxMaDemoServer.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(WxMaMessage wxMessage, Map<String, Object> context,
                   WxMaService service, WxSessionManager sessionManager) throws WxErrorException {
  System.out.println("收到消息:" + wxMessage.toString());
  service.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("收到信息为:" + wxMessage.toJson())
    .toUser(wxMessage.getFromUser()).build());
}
 
Example #7
Source File: WxMaDemoServer.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(WxMaMessage wxMessage, Map<String, Object> context,
                   WxMaService service, WxSessionManager sessionManager)
  throws WxErrorException {
  service.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("回复文本消息")
    .toUser(wxMessage.getFromUser()).build());
}
 
Example #8
Source File: WxMaMsgServiceImplTest.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
public void testSendKefuMessage() throws WxErrorException {
  TestConfig config = (TestConfig) this.wxService.getWxMaConfig();
  WxMaKefuMessage message = WxMaKefuMessage.newTextBuilder()
    .toUser(config.getOpenid())
    .content("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>")
    .build();

  this.wxService.getMsgService().sendKefuMsg(message);
}
 
Example #9
Source File: WxMaMsgServiceImpl.java    From weixin-java-tools with Apache License 2.0 4 votes vote down vote up
@Override
public boolean sendKefuMsg(WxMaKefuMessage message) throws WxErrorException {
  String responseContent = this.wxMaService.post(KEFU_MESSAGE_SEND_URL, message.toJson());
  return responseContent != null;
}
 
Example #10
Source File: TextMessageBuilder.java    From weixin-java-tools with Apache License 2.0 4 votes vote down vote up
@Override
public WxMaKefuMessage build() {
  WxMaKefuMessage m = super.build();
  m.setText(new WxMaKefuMessage.KfText(this.content));
  return m;
}
 
Example #11
Source File: ImageMessageBuilder.java    From weixin-java-tools with Apache License 2.0 4 votes vote down vote up
@Override
public WxMaKefuMessage build() {
  WxMaKefuMessage m = super.build();
  m.setImage(new WxMaKefuMessage.KfImage(this.mediaId));
  return m;
}
 
Example #12
Source File: WxMaMsgService.java    From weixin-java-tools with Apache License 2.0 2 votes vote down vote up
/**
 * <pre>
 * 发送客服消息
 * 详情请见: <a href="https://mp.weixin.qq.com/debug/wxadoc/dev/api/custommsg/conversation.html">发送客服消息</a>
 * 接口url格式:https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
 * </pre>
 */
boolean sendKefuMsg(WxMaKefuMessage message) throws WxErrorException;