钉钉添加方法参考技术手册https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq此代码为发送连接
import json
import requests
import sys
def send_msg(url):
headers = {'Content-Type': 'application/json;charset=utf-8'}
data = {
"msgtype": "link",
"link": {
"text": "内容",
"title": "标题",
"picUrl": "图片连接",
"messageUrl": "你需要发布的连接地址"
}
}
r = requests.post(url,data = json.dumps(data),headers=headers)
return r.text
if __name__ == '__main__':
url = '' #此处为丁丁机器人的地址,参考技术手册创建
print(send_msg(url))
此代码为发送语句
#丁丁机器人测试
import json
import requests
import sys
# reminders 提醒
def send_msg(url,reminders,msg):
headers = {'Content-Type': 'application/json;charset=utf-8'}
data = {
"msgtype": "text",
"text": {
"content": msg
},
"at": {
"atMobiles": [ #此处为需要@什么人。填写具体用户
"156xxxx8827",
"189xxxx8325"
],
"isAtAll": False #此处为是否@所有人
}
}
r = requests.post(url,data=json.dumps(data),headers=headers)
return r.text
if __name__ == '__main__':
msg = sys.argv[1]
reminders = ['15777889900']
url = '' #此处为丁丁机器人的地址,参考技术手册创建
# print(send_msg(url,msg))
print(send_msg(url, reminders, msg))
————————————————
版权声明:本文为CSDN博主「破蝶狂蜂」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/robertcid/java/article/details/90319570