钉钉群机器人定时发送消息并@所有人

您所在的位置:网站首页 钉钉群里如何@所有人收到 钉钉群机器人定时发送消息并@所有人

钉钉群机器人定时发送消息并@所有人

2024-06-23 20:02| 来源: 网络整理| 查看: 265

1.添加钉钉自定义群机器人

参考文章如下:

官方网址;https://open-doc.dingtalk.com/docs/doc.htm?spm=a219a.7629140.0.0.p2lr6t&treeId=257&articleId=105733&docType=1

2.如何使用自定义群机器人:

参考文章:https://open-doc.dingtalk.com/docs/doc.htm?spm=a219a.7629140.0.0.karFPe&treeId=257&articleId=105735&docType=1

注意:使用Java程序时需导入相关jar包

import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.HttpClient; import org.apache.http.clienthods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; public class ChatbotSend { public static String WEBHOOK_TOKEN = "https://oapi.dingtalk.com/robot/send?access_token=xxxxxx"; public static void main(String args[]) throws Exception{ HttpClient httpclient = HttpClients.createDefault(); HttpPost httppost = new HttpPost(WEBHOOK_TOKEN); httppost.addHeader("Content-Type", "application/json; charset=utf-8"); String msg = "我就是我,是颜色不一样的烟火"; String textMsg = "{ \"msgtype\": \"text\", \"text\": {\"content\": \"" + msg + "\"},\"at\":{\"isAtAll\":true} }"; StringEntity se = new StringEntity(textMsg, "utf-8"); httppost.setEntity(se); HttpResponse response = httpclient.execute(httppost); if (response.getStatusLine().getStatusCode()== HttpStatus.SC_OK){ String result= EntityUtils.toString(response.getEntity(), "utf-8"); System.out.println(result); } } }

jar包下载地址:https://blog.csdn.net/weixin_39549656/article/details/79156328

3.java程序打成jar包,并创建windows定时任务。 参考文章:https://www.cnblogs.com/xuezhezlr/p/7725301.html

注意:导出jar包,不同的eclipse版本导出的选项不同,要把jar包一起导出。

问题: 1.执行计划时,报:Unable to access jarfile 解决办法:.bat文件中jar的路径给全路径

@echo off java -jar E:\jar\test.jar pause

2.因为本机安装的jdk1.8,windows计划执行的时候报:has value '1.8',but'1.7' is required 解决办法: https://www.cnblogs.com/freedom-wy/p/6945936.html https://blog.csdn.net/manerfan/article/details/48492809



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3