python企业微信小程序发送信息

python企业微信小程序发送信息

在使用下面代码之前先配置webhook

教程如下:

https://www.bilibili.com/video/BV1oH4y1S7pN/?vd_source=bee29ac3f59b719e046019f637738769

然后使用如下代码就可以发消息了:

代码如下:

python 复制代码
#coding=gbk
import requests
def send(message:str):
    url = "机器人webhook地址"
    headers = {
        "Content-Type": "application/json"
    }
    data = {
        "msgtype": "text",
        "text": {
            "content": message,
            "mentioned_list": ["@all"]
        }
    }
    response = requests.post(url, headers=headers, json=data)
    records = response.json()
    return records
def sendAll(message:str):
    url = "机器人webhook地址"
    headers = {
        "Content-Type": "application/json"
    }
    data = {
        "msgtype": "text",
        "text": {
            "content": message,
            "mentioned_list": ["@all"]
        }
    }
    response = requests.post(url, headers=headers, json=data)
    records = response.json()
    return records


def test(stz):
    send(stz)

stz="测试程序"
test(stz)
相关推荐
四维迁跃几秒前
如何排查SQL存储过程死锁_分析死锁日志与索引优化
jvm·数据库·python
m0_74117333几秒前
如何检测SQL注入风险_利用模糊测试技术发现漏洞
jvm·数据库·python
c++之路几秒前
C++ 模板
linux·开发语言·c++
幻影七幻1 分钟前
js中send的作用和使用 $.ajax的作用
开发语言·前端·javascript
xcbrand3 分钟前
餐饮品牌全案公司哪家可靠
运维·python
鸿儒5176 分钟前
记录一个C++ Windows程序移植到Linux系统的bug
开发语言·c++·bug
浮尘笔记10 分钟前
在Snowy后台无需编码实现自动化生成CRUD操作流程
java·开发语言·经验分享·spring boot·后端·程序人生·mybatis
2401_8463395611 分钟前
CSS如何解决Less与CSS兼容性问题_通过配置文件实现平滑过渡与混合开发
jvm·数据库·python
qq_4138474012 分钟前
CSS如何控制全屏显示的元素样式
jvm·数据库·python
scan72415 分钟前
上下文摘要
python