zoukankan      html  css  js  c++  java
  • 钉钉机器人

    普通发送消息 
           Map<String, Object> params = new HashMap<>(3);
            params.put("msgtype", "text");
            Map<String, Object> text = new HashMap<>(1);
            text.put("content", content);
            params.put("text", text);
            String dingUrl = "复制你的机器人地址如:https://oapi.dingtalk.com/robot/send?access_token=jjjjjjiiiiiiii";
            HttpWebUtils.doPostJson(dingUrl, params, "UTF-8", 3000, 3000);

      

    public static String doPostJson(String url, Map<String, Object> reqDataMap, String
                charset, int socketTimeout, int connectTimeout) throws IOException {
            CloseableHttpClient httpClient = HttpClients.createDefault();
    
    
            HttpPost httpPost = new HttpPost(url);
    
    
            StringEntity sn = new StringEntity(JSONObject.toJSONString(reqDataMap), "UTF-8");
            sn.setContentEncoding(charset);
            sn.setContentType("application/json; charset=UTF-8");
            httpPost.setEntity(sn);
    
    
            //LOG.biz("************** httpPost url: " + url);
            //LOG.biz("** Header: " + JSON.toJSONString(httpPost.getAllHeaders()));
            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(socketTimeout).setConnectTimeout(connectTimeout).build();//设置请求和传输超时时间
            httpPost.setConfig(requestConfig);
    
            CloseableHttpResponse response = httpClient.execute(httpPost);
            HttpEntity httpEntity = response.getEntity();
            return EntityUtils.toString(httpEntity, charset);
        }
    }
  • 相关阅读:
    基于maven构建javaweb项目思路梳理及改进 在路上
    分圆多项式整理
    第03次作业栈和队列
    C语言第二次实验报告
    week01绪论作业
    第02次作业线性表
    C语言第一次实验报告
    工作流的问题
    无法使用Outlook 2003 Out Of Office Assisant
    刷机
  • 原文地址:https://www.cnblogs.com/ysg520/p/11242728.html
Copyright © 2011-2022 走看看