Shell中通过机器人发送钉钉群消息

场景:在平时的工作中,经常需要执行一些定时任务,并且当定时任务执行失败后需要告警出来到钉钉群,使用[钉钉机器人]可以简单快速的帮我们完成这件事情。


  • 简单使用



curl 'https://oapi.dingtalk.com/robot/send?access_token=9e2549f6a0bb28767bdexxxxxxxxxxxxxxxxxx81975c981005abbd' \
   -H 'Content-Type: application/json' \
   -d '
  {"msgtype": "text", 
    "text": {
        "content": "我就是我, 是不一样的烟火"
     }
  }'

效果图:

clipboard.png



  • 发送文本内容并@指定的人


curl 'https://oapi.dingtalk.com/robot/send?access_token=9e2549f6a0xxxxxxxxxxxxxxxxxx447981975c981005abbd' -H 'Content-Type: application/json' -d '{"msgtype":"text","text":{"content":"我就是我, 是不一样的烟火"},"at":{"atMobiles":["176xxxx1234"],"isAtAll":false}}'

效果图:

1531149651(1).png

猜你喜欢

转载自blog.51cto.com/simplelife/2139494