wx-tools 图文相关API
2023-03-22 17:20 更新
包括如下接口:
- addNewsMedia - 新增图文
- updateNewsInfo - 修改图文
3.5.1 addNewsMedia 添加图文
WxNewsInfo news1 = new WxNewsInfo();
news1.setTitle("标题1");
news1.setThumb_media_id("图片media_id");
news1.setContent("xxx");
//....设置图文内容
WxNewsInfo news2 = new WxNewsInfo();
news2.setTitle("标题1");
news2.setThumb_media_id("图片media_id");
news2.setContent("xxx");
List<WxNewsInfo> newsList = new ArrayList<>();
newsList.add(news1);
newsList.add(news2);
try {
String mediaId = iService.addNewsMedia(newsList);
} catch (WxErrorException e) {
e.printStackTrace();
}
3.5.2 updateNewsInfo 修改图文内容
WxNewsInfo news1 = new WxNewsInfo();
news1.setTitle("标题1");
news1.setThumb_media_id("图片media_id");
news1.setContent("xxx");
try {
//参数1:media_id;参数2:图文位置下标。从0开始;参数3:新的图文对象
WxError result = iService.updateNewsInfo("media_id", 0, news1);
} catch (WxErrorException e) {
e.printStackTrace();
}
以上内容是否对您有帮助:
更多建议: