1. 获取素材id
SysWx sysWx = weixinService.getSysWx(originalId); // 自定义方法,为了获得微信配置信息 WxMpServiceImpl wxmp = WeixinUtils.getWxService(sysWx); // 获取WxMpService WxMpMaterialCountResult cnt = wxmp.materialCount(); WxMpMaterialFileBatchGetResult resutl = wxmp.materialFileBatchGet(WxConsts.XML_MSG_NEWS, 0, 1); List<WxMaterialFileBatchGetNewsItem> list = resutl.getItems(); System.out.println(list.get(0).getMediaId());
2. 发送图文消息
WxMpMassOpenIdsMessage news = new WxMpMassOpenIdsMessage(); news.setContent(""); news.setMediaId("m6cPGXfUlgA9QT5D93pYCVWGMnej_6L0EWZJWYDSkbE"); news.setMsgType(WxConsts.MASS_MSG_NEWS); news.addUser("oirzkjj2ggMAt1pEoordaJgOE_60"); news.addUser(""); wxmp.massOpenIdsMessageSend(news);
效果截图: