钉钉群机器人发送消息通知
-
建立钉钉群,新建机器人
群设置 --》 智能群助手
-
发送卡片
DingTalkClient client = new DefaultDingTalkClient(DingDing_URL);
OapiRobotSendRequest request = new OapiRobotSendRequest();
request.setMsgtype("actionCard");
//卡片内容
OapiRobotSendRequest.Actioncard actioncard = new OapiRobotSendRequest.Actioncard();
actioncard.setTitle(DateUtils.getTodayDate() + "BD获客排名");
actioncard.setText("### " + DateUtils.getTodayDate() + "BD获客排名");
actioncard.setBtnOrientation("0");
//按钮
List<OapiRobotSendRequest.Btns> btns = Lists.newArrayList();
OapiRobotSendRequest.Btns btn = new OapiRobotSendRequest.Btns();
btn.setTitle("下载");
btn.setActionURL(url.contains("http") ? url : "https://" + url);
btns.add(btn);
actioncard.setBtns(btns);
request.setActionCard(actioncard);
//at所有人
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
at.setIsAtAll(true);
request.setAt(at);
//发送通知
OapiRobotSendResponse response = client.execute(request);
log.info("sendDingDing response = {}", JSON.toJSONString(response));