You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import requests
import json
def send_dingtalk_message ( webhook_url , message , all ) :
# 构建钉钉消息
message = {
" msgtype " : " text " ,
" text " : {
" content " : message
} ,
" at " : {
" isAtAll " : all
}
}
# 发送HTTP POST请求
headers = {
" Content-Type " : " application/json "
}
# 将消息转换为JSON格式
message_json = json . dumps ( message )
# 发送请求
requests . post ( webhook_url , data = message_json , headers = headers )
if __name__ == " __main__ " :
#webhook_url: 机器人的token号码, message:呈现内容。all: 是否@全体发送
webhook_url = ' https://oapi.dingtalk.com/robot/send?access_token=ab20a597f1c8a6c8c7a68a2e4ed724af7c5ece4678616ac6efe95fb722583f0d '
message = ' 更新禅道 '
all = True
send_dingtalk_message ( webhook_url , message , all )