1.在钉钉群里添加一个自定义的机器

在设置说明中无需开启Outgoing机制

红色箭头指的信息很重要后面脚本会用到

2.脚本

#!/usr/bin/python
# -*- coding: utf-8 -*-
# Author: aiker@gdedu.ml
# My blog http://m51cto.51cto.blog.com
import requests
import json
import sys
import os headers = {'Content-Type': 'application/json;charset=utf-8'}
api_url = "https://oapi.dingtalk.com/robot/send?access_token=37e23308d1b84eb4ac34566e03c4c4e74bxxxxxxxxxxxxxx" def msg(text):
json_text= {
"msgtype": "text",
"at": {
"atMobiles": [
"13xxxxxxx80"
],
"isAtAll": False
},
"text": {
"content": text
}
}
print requests.post(api_url,json.dumps(json_text),headers=headers).content if __name__ == '__main__':
text = sys.argv[1]
msg(text)

chmod +x dingdingrobot.py

脚本测试,python2

python dingdingrobot.py 123

参考博客:https://blog.51cto.com/m51cto/2051945

最新文章

  1. ABP(现代ASP.NET样板开发框架)系列之21、ABP展现层——Javascript函数库
  2. 性能优化方法(Z)
  3. Java序列化格式详解
  4. SQL语句判断是否为今天或昨天
  5. ubuntu下添加/删除启动服务项
  6. ES6中的Class
  7. 通过Jmeter完成WebTours的性能测试
  8. 剑指offer系列54---数组中出现次数超过一半的数
  9. 65.OV7725图像倒置180度
  10. ggplot2 scale相关设置
  11. (转载)DBCP、C3P0、Proxool 、 BoneCP开源连接池的比较
  12. 通过tokenPlease()函数获取accessToken
  13. Java开发速度神器Lombok,Eclipse端安装使用教程
  14. A previous installation of Qt5 Visual Studio Add-in was detected. Please uninstall it before running this installer解决办法
  15. JQuery EasyUI 表单
  16. JavaScript中的事件冒泡?事件传播的解释
  17. 网络编程 -- RPC实现原理 -- RPC -- 迭代版本V2 -- 本地方法调用 整合 Spring
  18. hdu 2289 要二分的杯子
  19. gdb 小技巧
  20. In MySQL, a zero number equals any string

热门文章

  1. 021 Ceph关于too few PGs per OSD的问题
  2. 通过nginx搭建基于python的web环境
  3. 中小型企业级 IPS 部署
  4. Windows服务器管理--批量管理工具
  5. VisitorPattern(访问者模式)-----Java/.Net
  6. kubernetes基础——一文读懂k8s
  7. 简单了解linux内核
  8. 二、Spring Cloud之注册中心 Eureka
  9. OpenLayers4 隐藏(hide)Feature
  10. CS0656 缺少编译器要求的成员“Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create”