import json import requests def sendmessage(message): url = 'https://oapi.dingtalk.com/robot/send?access_xxxxxxx' #钉钉机器人的webhook地址 HEADERS = { "Content-Type": "application/json ;charset=utf-8 " } message = message String_textMsg = { "msgtype": "text", "text": {"content": message}, "at": { "atMobiles": [ "130xxxxxxxx" #如果需要@某人,这里写他的手机号 ], "isAtAll": 1 #如果需要@所有人,这些写1 } } String_textMsg = json.dumps(String_textMsg) res = requests.post(url, data=String_textMsg, headers=HEADERS) print(res.text) if '__name__' == '__main__': sendmessage('test')
##钉钉开放平台地址
https://open-doc.dingtalk.com/docs/doc.htm?treeId=257&articleId=105735&docType=1
钉钉的webhook机器人地址