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)
相关推荐
m0_527034332 分钟前
异步任务审核系统设计:消息队列、超时重试与失败补偿
java·大数据·开发语言
一朵好运莲27 分钟前
智能体使用 Chrome DevTools MCP 调试浏览器
开发语言·javascript·react.js
zzzll111130 分钟前
Loop Engineering:循环工程的原理、实践与应用
java·数据库·python
秋田君31 分钟前
QT_JSON文件操作
开发语言·qt·json
老赵的博客32 分钟前
可维护性 可扩展性 可复用性
开发语言·c++
sibylyue40 分钟前
工作流表单和流程设计前端
开发语言·javascript·开源
一个游离的指针1 小时前
JS中的对象的相关概念
开发语言·javascript·原型模式
jaysee-sjc1 小时前
【JavaWeb】Tlias智能学习辅助系统|后端Web实战(登录认证)
java·开发语言·前端·学习·mybatis
刘新洲1 小时前
别再只做会聊天的 Agent:我用 1 天把工具调用做成了可验证、可评测的工程系统
人工智能·python·openai