java接入钉钉机器人,进行风险报警

public static void sendDingTalkRisk(Integer sbszid,Long bbh) throws IOException {
    HttpClient httpClient= HttpClients.createDefault();
    HttpPost httpPost=new HttpPost("https://oapi.dingtalk.com/robot/send?access_token=d8615ed6132c0837e41de61b52577b751f2ca54a43ade48d8912dfeb7e867143");
    httpPost.addHeader("Content-Type", "application/json; charset=utf-8");
    JSONObject bodys = new JSONObject();
    bodys.put("msgtype","text");
    JSONObject text=new JSONObject();
    String sendMessage = "";
    sendMessage ="申报税种id:"+sbszid+",版本号:"+bbh+"上传失败啦,请注意查看";
    text.put("content",sendMessage);
    bodys.put("text",text);
    JSONObject at=new JSONObject();
    at.put("isAtAll",true);
    bodys.put("at",at);
    StringEntity se = new StringEntity(bodys.toJSONString(), "utf-8");
    httpPost.setEntity(se);
    httpClient.execute(httpPost);
}

你可能感兴趣的:(java)