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
# 配置你的Webhook URL
webhook_url = ' https://oapi.dingtalk.com/robot/send?access_token= '
def send_dingtalk_message ( token , all ) :
# 构建钉钉消息
message = {
" msgtype " : " text " ,
" text " : {
" content " : " 小助手提醒大家要写禅道啦~。 "
} ,
" at " : {
" isAtAll " : all
}
}
# 发送HTTP POST请求
headers = {
" Content-Type " : " application/json "
}
# 将消息转换为JSON格式
message_json = json . dumps ( message )
# 发送请求
url = webhook_url + token
requests . post ( url , data = message_json , headers = headers )
if __name__ == " __main__ " :
#token: 机器人的token号码, all: 是否@全体发送
send_dingtalk_message ( ' ab20a597f1c8a6c8c7a68a2e4ed724af7c5ece4678616ac6efe95fb722583f0d ' , False )