微信消息推送简单版
1.引入依赖
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-cp</artifactId>
<version>3.2.0</version>
</dependency>
2.简单代码
NewsBuilder news = WxCpMessage.NEWS();
news.agentId(Integer.valueOf("agentId")).toUser("userName")
.safe("0");
NewArticle article = new NewArticle();
article.setTitle("title");
article.setDescription("消息以");
article.setUrl("http://www.baidu.com");
news.addArticle(article);
WxCpMessage wxCpMessage= news.build();
String content= wxCpMessage.toJson();
System.out.println(content);
WxCpInMemoryConfigStorage config = new WxCpInMemoryConfigStorage();
config.setCorpId("corpId");
config.setCorpSecret("corpSecret");
WxCpServiceImpl wx = new WxCpServiceImpl();
wx.setWxCpConfigStorage(config);
String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send";
String res= wx.post(url,content);
System.out.println(res);
注释:其中corpId,corpSecret 通过企业号获得
3.附企业微信 接口文档地址
https://qydev.weixin.qq.com/wiki/index.php?title=%E5%8F%91%E9%80%81%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E