python+钉钉机器人发送消息

#钉钉机器人
import json
import requests
import sys

# reminders 提醒
def send_msg_to_dingding(msg, 
                         url = r'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxxxxxx', 
                         reminders=[]):
    headers = {
        'Content-Type': 'application/json;charset=utf-8'
        }
    data = {
    "msgtype": "text",
    "text": {"content": msg},
    "at": {
            "atMobiles": reminders,#此处为需要@什么人。填写具体用户
            "isAtAll": False  #此处为是否@所有人
            }
    }

    ret = requests.post(url,data=json.dumps(data),headers=headers)
    return ret.text

'''
if __name__ == '__main__':
    msg = r'jenkins test'
    reminders = []
    url = r'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxxxxxx'  
    #此处为丁丁机器人的地址,参考技术手册创建
    # print(send_msg(url,msg))
    print(send_msg(url, reminders, msg))
'''

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值