@Test public void testSendUniformMsg() throws WxErrorException { TestConfig config = (TestConfig) this.wxService.getWxMaConfig(); WxMaUniformMessage message = WxMaUniformMessage.builder() .isMpTemplateMsg(false) .toUser(config.getOpenid()) .page("page/page/index") .templateId("TEMPLATE_ID") .formId("FORMID") .emphasisKeyword("keyword1.DATA") .build(); message.addData(new WxMaTemplateData("keyword1", "339208499")) .addData(new WxMaTemplateData("keyword2", "2015年01月05日 12:30")) .addData(new WxMaTemplateData("keyword3", "腾讯微信总部")) .addData(new WxMaTemplateData("keyword4", "广州市海珠区新港中路397号")); this.wxService.getMsgService().sendUniformMsg(message); }
@Override public void sendUniformMsg(WxMaUniformMessage uniformMessage) throws WxErrorException { String responseContent = this.wxMaService.post(UNIFORM_MSG_SEND_URL, uniformMessage.toJson()); JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent)); } }
WxMaMsgServiceImpl implements WxMaMsgService { @Override public void sendUniformMsg(WxMaUniformMessage uniformMessage) throws WxErrorException { String responseContent = this.wxMaService.post(UNIFORM_MSG_SEND_URL, uniformMessage.toJson()); JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent)); } } }
WxMaMsgServiceImpl implements WxMaMsgService { @Override public void sendUniformMsg(WxMaUniformMessage uniformMessage) throws WxErrorException { String responseContent = this.wxMaService.post(UNIFORM_MSG_SEND_URL, uniformMessage.toJson()); JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent)); } } WxMaMsgServiceImpl(WxMaService wxMaService); }
WxMaMsgServiceImpl implements WxMaMsgService { @Override public void sendUniformMsg(WxMaUniformMessage uniformMessage) throws WxErrorException { String responseContent = this.wxMaService.post(UNIFORM_MSG_SEND_URL, uniformMessage.toJson()); JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent)); } } WxMaMsgServiceImpl(WxMaService wxMaService); @Override boolean sendKefuMsg(WxMaKefuMessage message); @Override void sendTemplateMsg(WxMaTemplateMessage templateMessage); @Override void sendUniformMsg(WxMaUniformMessage uniformMessage); }
WxMaMsgServiceImpl implements WxMaMsgService { @Override public void sendUniformMsg(WxMaUniformMessage uniformMessage) throws WxErrorException { String responseContent = this.wxMaService.post(UNIFORM_MSG_SEND_URL, uniformMessage.toJson()); JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent)); } } WxMaMsgServiceImpl(WxMaService wxMaService); @Override boolean sendKefuMsg(WxMaKefuMessage message); @Override void sendTemplateMsg(WxMaTemplateMessage templateMessage); @Override void sendUniformMsg(WxMaUniformMessage uniformMessage);  }