@Test public void testSendSubscribeMessage() throws WxErrorException { TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpSubscribeMessage message = WxMpSubscribeMessage.builder() .title("weixin test") .toUser(configStorage.getOpenid()) .scene("1000") .contentColor("#FF0000") .contentValue("Send subscribe message test") .build(); try { boolean send = this.wxService.getSubscribeMsgService().sendSubscribeMessage(message); Assert.assertTrue(send); } catch (WxErrorException e) { if (e.getError().getErrorCode() != 43101) { throw e; } } }
@Override public boolean sendSubscribeMessage(WxMpSubscribeMessage message) throws WxErrorException { if (message.getTemplateId() == null) { message.setTemplateId(this.wxMpService.getWxMpConfigStorage().getTemplateId()); } String responseContent = this.wxMpService.post(SEND_MESSAGE_URL, message.toJson()); return responseContent != null; }
WxMpSubscribeMsgServiceImpl implements WxMpSubscribeMsgService { @Override public boolean sendSubscribeMessage(WxMpSubscribeMessage message) throws WxErrorException { if (message.getTemplateId() == null) { message.setTemplateId(this.wxMpService.getWxMpConfigStorage().getTemplateId()); } String responseContent = this.wxMpService.post(SEND_MESSAGE_URL, message.toJson()); return responseContent != null; } }
WxMpSubscribeMsgServiceImpl implements WxMpSubscribeMsgService { @Override public boolean sendSubscribeMessage(WxMpSubscribeMessage message) throws WxErrorException { if (message.getTemplateId() == null) { message.setTemplateId(this.wxMpService.getWxMpConfigStorage().getTemplateId()); } String responseContent = this.wxMpService.post(SEND_MESSAGE_URL, message.toJson()); return responseContent != null; } WxMpSubscribeMsgServiceImpl(WxMpService wxMpService); }
WxMpSubscribeMsgServiceImpl implements WxMpSubscribeMsgService { @Override public boolean sendSubscribeMessage(WxMpSubscribeMessage message) throws WxErrorException { if (message.getTemplateId() == null) { message.setTemplateId(this.wxMpService.getWxMpConfigStorage().getTemplateId()); } String responseContent = this.wxMpService.post(SEND_MESSAGE_URL, message.toJson()); return responseContent != null; } WxMpSubscribeMsgServiceImpl(WxMpService wxMpService); @Override String subscribeMsgAuthorizationUrl(String redirectURI, int scene, String reserved); @Override boolean sendSubscribeMessage(WxMpSubscribeMessage message); }
WxMpSubscribeMsgServiceImpl implements WxMpSubscribeMsgService { @Override public boolean sendSubscribeMessage(WxMpSubscribeMessage message) throws WxErrorException { if (message.getTemplateId() == null) { message.setTemplateId(this.wxMpService.getWxMpConfigStorage().getTemplateId()); } String responseContent = this.wxMpService.post(SEND_MESSAGE_URL, message.toJson()); return responseContent != null; } WxMpSubscribeMsgServiceImpl(WxMpService wxMpService); @Override String subscribeMsgAuthorizationUrl(String redirectURI, int scene, String reserved); @Override boolean sendSubscribeMessage(WxMpSubscribeMessage message);  }