作者: littleboy 2026-02-12 11:53:19

WXWork-API

创建群机器人进行信息的【接收】与【发送】

创建webhook

群右上角…号 -> 信息推送 -> 创建后产生Webhook地址。

只能是企业群聊才可以,外部群聊不行。

群消息推送

消息推送配置说明

1
2
3
4
5
6
7
8
9
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=693axxx6-7aoc-4bc4-97a0-0ec2sifa5aaa' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "text",
"text": {
"content": "hello world"
}
}'

三、支持的消息类型

除了文本消息,企业微信 Webhook 还支持以下消息类型:

  1. Markdown 消息

    • 请求体示例:

      1
      2
      3
      4
      5
      6
      {
      "msgtype": "markdown",
      "markdown": {
      "content": "**加粗文字**\n> 引用内容"
      }
      }
  2. 图片消息

  • 请求头实例:

    1
    2
    3
    4
    5
    6
    7
    {
    "msgtype": "image",
    "image": {
    "base64": "DATA",
    "md5": "MD5"
    }
    }

    base64是图片内容的base64编码

    md5 是图片内容(base64编码前)的md5值

注:图片(base64编码前)最大不能超过2M,支持JPG,PNG格式

  1. 文件消息

    • 通过下文的上传文件接口获取

      1
      media_id

      ,然后发送:

      1
      2
      3
      4
      5
      6
      {
      "msgtype": "file",
      "file": {
      "media_id": "your_media_id"
      }
      }
  2. 图文消息

    • 请求体示例:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      {
      "msgtype": "news",
      "news": {
      "articles": [
      {
      "title": "标题",
      "description": "描述",
      "url": "https://example.com",
      "picurl": "https://example.com/image.png"
      }
      ]
      }
      }

群消息接收

消息推送配置说明

参考

企业微信如何获取 Webhook 实现消息推送 - 知行小屋