企业微信上使用python发送机器人消息

 

企业微信上使用python,发送机器人消息:

import json
import requests



# 注意这段key一定要妥善保护 不能暴露到外部空间  否则安全隐患很多
wecom_api_url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=*******"

headers = {'Content-Type': 'application/json;charset=utf-8'}
payload = {
    "msgtype": "text",
    "text": {
        "content": "告警消息!!"
    },

}
res = requests.post(wecom_api_url, json.dumps(payload), headers=headers)
print(res.status_code)
print(res.text)

 

posted @ 2021-09-27 16:33  TonyHuang123  阅读(526)  评论(0编辑  收藏  举报