企业微信文本消息推送简单版

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值