Giter Club home page Giter Club logo

qyapi-wechat-sdk's Introduction

企业微信 Java Client

Usage

1、Add dependency

<dependency>
    <groupId>com.cc.pub</groupId>
    <artifactId>qyapi-wechat-sdk</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

2、Configuration

@Configuration
@Data
public class CorpWechatConfig {

    @Value("${corp.wechat.corpId}")
    private String corpId;

    @Value("${corp.wechat.secret}")
    private String secret;

    @Value("${corp.wechat.agentId}")
    private String agentId;

    @Bean
    public CorpWeChatService corpWeChatService() {
        return new CorpWeChatService(corpId, secret, agentId);
    }
}

3、Invoke in java code

    List<String> tags = new ArrayList<>();
    tags.add("1"); // java 开发
    // 发送给指定tag ,标签ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为@all时忽略本参数
    corpWeChatService.sendByTag(tags, "领奖通知", "<div class=\"gray\">2018年05月3日</div> <div class=\"normal\">恭喜你抽中iPhone 7一台,领奖码:xe7y</div><div class=\"highlight\">请于2018年05月10日前联系行政同事领取</div>");

    List<String> users = new ArrayList<>();
    users.add("qy01eaba0fa6470db69cb58a4633");
    // 发送给指定用户,成员ID列表(消息接收者,多个接收者用‘|’分隔,最多支持1000个)。特殊情况:指定为@all,则向关注该企业应用的全部成员发送
    corpWeChatService.sendByUser(users, "领奖通知", "<div class=\"gray\">2018年05月3日</div> <div class=\"normal\">恭喜你抽中iPhone 7一台,领奖码:xe7y</div><div class=\"highlight\">请于2018年05月10日前联系行政同事领取</div>");

    // 部门ID:1842014604 研发部
    List<String> partys = new ArrayList<>();
    partys.add("1842014604");
    // 发送给指定部门, 部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为@all时忽略本参数
    // corpWeChatService.sendByParty(partys, "企业应用消息测试。不用理。");

4、showcase

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.