为了避免工作疏忽,钉钉推送通知到个人(实例)

public static void main(String args[]){

    // 获取token
    JSONObject json = new JSONObject();
    json.put("appKey", "应用程序的唯一标识符");
    json.put("appSecret", "应用程序(App)的密钥");
    String URL = "https://api.dingtalk.com/v1.0/oauth2/accessToken";
    String TOKEN = null;
    try {
        TOKEN = HttpRequest.post(URL).body(json.toString()).timeout(10000).execute().body();
        JSONObject tokenJson = JSONObject.parseObject(TOKEN);
        if (tokenJson.containsKey("accessToken")) {
            String sendUrl = "https://api.dingtalk.com/v1.0/robot/oToMessages/batchSend";
            TOKEN = tokenJson.getString("accessToken");
            JSONObject sendParam = new JSONObject();
            sendParam.put("x-acs-dingtalk-access-token", TOKEN);
            JSONObject body = new JSONObject();
            body.put("robotCode", "robotCode");// 机器人代码&#

你可能感兴趣的:(钉钉,java,前端)