美文网首页
python 企业微信发送通知接口

python 企业微信发送通知接口

作者: 路破格 | 来源:发表于2020-06-23 16:57 被阅读0次
#-*- coding=utf-8 -*-
#-*- encoding:utf-8 -*-

import json
import requests

def send_wechat_robot(
        body = "", 
        keyid = ""):
    request_url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=%s" % keyid
    datas = {
        "msgtype": "text",
        "text": {"content": body}
    }
    http_headers = {"Content-Type": "application/json"}
    request_datas = json.dumps(datas, ensure_ascii = False)
    req = requests.post(
        url = request_url,
        data = request_datas,
        headers = http_headers,
        timeout = 10
    )
    req.close()

相关文章

网友评论

      本文标题:python 企业微信发送通知接口

      本文链接:https://www.haomeiwen.com/subject/lkvhfktx.html