1,钉钉群内添加机器人 智能群助手-添加机器人
2,获取Webhook
3.在项目中添加代码
public void dingTask(String string){
try{
//钉钉机器人地址(配置机器人的webhook)
String dingUrl = "https://oapi.dingtalk.com/robot/send?access_token=11111111";
//是否通知所有人
boolean isAtAll = false;
//通知具体人的手机号码列表
List<String> mobileList = Lists.newArrayList();
mobileList.add("133*******");
//钉钉机器人消息内容
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String NewData = sdf.format(date);
String content = NewData+"_"+string;
//组装请求内容
String reqStr = buildReqStr(content, isAtAll, mobileList);
//推送消息(http请求)
String result = postJson(dingUrl, reqStr);
//System.out.println("result == " + result);
}catch (Exception e){
e.printStackTrace();
}
}