{ "msgtype":"link", "link":{ "messageUrl":"http://118.25.182.23:8051/img/3e8cc4bc-e6ac-4ebc-9ff3-ae005aedb13d.png", "picUrl":"http://118.25.182.23:8051/img/3e8cc4bc-e6ac-4ebc-9ff3-ae005aedb13d.png", "title":"明天开始盒饭啦", "text":"接口场景:国际站线上业务监控 接口名称:15确认下订单 接口地址:https://appapi.shownow.live/shownowapi/buyer/v1/orders/order 接口异常:Value expected to match regexp 成功, but it did not match: Value expected to match regexp 200, but it did not match: [12502002]" }, "at":{ "atMobiles":[ "18922233221" ], "isAtAll":false } }
04_msgtype=markdown@在群里的人,text和@中都要出现一样都手机号才行
{ "msgtype":"markdown", "markdown":{ "title":"明天开始盒饭啦", "text":"### 国际站线上业务监控 @18911120 接口名称:15确认下订单 接口地址:https://appapi.shownow.live/shownowapi/buyer/v1/orders/order 接口异常:Value expected to match regexp 成功, but it did not match: ![screenshot](http://118.25.182.23:8051/img/3e8cc4bc-e6ac-4ebc-9ff3-ae005aedb13d.png) ### Value expected to match regexp 200, but it did not match: [12502002]" }, "at":{ "atMobiles":[ "189443334433" ], "isAtAll":false } }
05_msgtype=markdown,以前有个bug,后来钉钉修复了,之前人不在群里,写了手机号,也能得到姓名
{ "msgtype":"markdown", "markdown":{ "title":"明天开始盒饭啦", "text":"### 国际站线上业务监控 @123123111 接口名称:15确认下订单 接口地址:https://appapi.shownow.live/shownowapi/buyer/v1/orders/order 接口异常:Value expected to match regexp 成功, but it did not match: ![screenshot](http://118.25.182.23:8051/img/3e8cc4bc-e6ac-4ebc-9ff3-ae005aedb13d.png) ### Value expected to match regexp 200, but it did not match: [12502002]" }, "at":{ "atMobiles":[ "123123111" ], "isAtAll":false } }
06_整体跳转ActionCard类型,没法@对应的人
{ "actionCard": { "title": "国际站线上业务监控", "text": "![screenshot](@lADOpwk3K80C0M0FoA) ### 国际站线上业务监控 接口场景:国际站线上业务监控 接口名称:15确认下订单 接口地址:https://appapi.shownow.live/shownowapi/buyer/v1/orders/order 接口异常:Value expected to match regexp 成功, but it did not match: Value expected to match regexp 200, but it did not match: [12502002]", "hideAvatar": "1", "btnOrientation": "1", "singleTitle" : "阅读全文", "singleURL" : "https://www. moretickets.com/" }, "msgtype": "actionCard", "at":{ "atMobiles":[ "111111111111" ], "isAtAll":false } }
07_独立跳转ActionCard类型,没法@对应的人
{ "actionCard": { "title": "国际站线上业务监控", "text": "![screenshot](@lADOpwk3K80C0M0FoA) ### 国际站线上业务监控 接口场景:国际站线上业务监控 接口名称:15确认下订单 接口地址:https://appapi.shownow.live/shownowapi/buyer/v1/orders/order 接口异常:Value expected to match regexp 成功, but it did not match: Value expected to match regexp 200, but it did not match: [12502002]", "hideAvatar": "0", "btnOrientation": "1", "btns": [ { "title": "内容不错", "actionURL": "https://www.moretickets.com/" }, { "title": "不感兴趣", "actionURL": "https://www.moretickets.com/" } ] }, "msgtype": "actionCard" }
08_FeedCard类型,没法@对应的人
{ "feedCard": { "links": [ { "title": "国际站脚本监控", "messageURL": "https://www.moretickets.com/", "picURL": "http://118.25.182.23:8051/img/3e8cc4bc-e6ac-4ebc-9ff3-ae005aedb13d.png" }, { "title": "国际站脚本监控222", "messageURL": "https://www.moretickets.com/", "picURL": "http://118.25.182.23:8051/img/3e8cc4bc-e6ac-4ebc-9ff3-ae005aedb13d.png" }, { "title": "国际站脚本监控333", "messageURL": "https://www.moretickets.com/", "picURL": "http://118.25.182.23:8051/img/3e8cc4bc-e6ac-4ebc-9ff3-ae005aedb13d.png" }, { "title": "摩天轮脚本监控", "messageURL": "https://www.moretickets.com/", "picURL": "http://118.25.182.23:8051/img/3e8cc4bc-e6ac-4ebc-9ff3-ae005aedb13d.png" } ] }, "msgtype": "feedCard" }
直接用命令行shell命令
curl 'https://oapi.dingtalk.com/robot/send?access_token=xx'
-H 'Content-Type: application/json'
-d '消息体'
目前的消息类型支持以后5种类型
文本 (text)、
链接 (link)、
markdown(markdown)、
ActionCard、
FeedCard消息类型
文本类型支持内容加密模式,其余的根本不能输入content,只能选用其他加密方式,比如密钥模式
curl 'https://oapi.dingtalk.com/robot/send?access_token=5xx'
-H 'Content-Type: application/json'
-d '{
"msgtype":"text",
"text":{
"content":"接口测试, html上传去哪儿@xx"
},
"at":{
"atMobiles":[
"xx"
],
"isAtAll":false
}
}'
链接 (link)消息类型
{ "msgtype": "link", "link": { "content":"接口测试 fail code", "text": "共计xx用例,成功200,失败0", "title": "中台show接口测试报告", "picUrl": "https://www. .com/images/logo-b17998409b.png", "messageUrl": "https://www.dingtalk.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI" } }
public static String secret = "SEC2133c0be433d15030f4f3a629cf5b2b046b4acc3eba824231b550e0c99cf942f"; public static void main(String[] args) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException { Long timestamp = System.currentTimeMillis(); System.out.println(timestamp); String stringToSign = timestamp + " " + secret; Mac mac = Mac.getInstance("HmacSHA256"); mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256")); byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8")); String u = URLEncoder.encode(new String(Base64.encodeBytes(signData)),"UTF-8"); System.out.println(u); }
01_msgtype=text
1 { 2 "msgtype":"text", 3 "text":{ 4 "content":"标题:测试标题 征文: 测试内容 页脚:我手机饿了" 5 }, 6 "at":{ 7 "atMobiles": ["18900000000"], 8 "isAtAll": false 9 } 10 }
02_msgtype=text且@对应的人或全部的人
{ "msgtype":"text", "at":{ "atMobiles":[ "18922222222","15922233445" ], "isAtAll":false }, "text":{ "content":"标题:测试标题 征文: 测试内容 页脚:我手机饿了" } }
03_msgtype=link