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)
相关推荐
橙子1991101611 小时前
Java/Kotlin 与并发
java·python·kotlin
prince_zxill11 小时前
Raspberry PI传感器数据上云:Python IoT集成
开发语言·python·物联网
etcix11 小时前
go cli translator that use bing api and youdao api
开发语言·elasticsearch·golang
亚历山大海11 小时前
AiPPT接口文件PHP版本全,智能生成PPT文件并下载
开发语言·ai·php
ノBye~11 小时前
Spring的IOC详解
java·开发语言
willhuo11 小时前
全能文档解析服务doc-mcp-server
python·ai
147API11 小时前
Claude 模型选型:Opus/Sonnet/Haiku + 成本/限速预算(Kotlin)
android·开发语言·kotlin·147api
mr_LuoWei200911 小时前
自定义的中文脚本解释器来实现对excel自动化处理(二)
运维·python·自动化
MoSTChillax11 小时前
新手 3 个文件跑通前端 + Flask + MySQL(最小可行 CRUD)
数据库·python·mysql·flask