API 文档

阅读当前文档内容。

文档

API 接口文档

基础信息

  • 基础地址https://bot-admin.minapp.xin
  • 鉴权参数secret(放在 query string)
  • 请求格式Content-Type: application/json
  • 兼容性:接口兼容企微官方机器人的 webhook

1. 发送消息

  • 接口地址:POST /api/send
  • 必填参数secretconversation_id
  • 说明:消息内容放在 JSON body 中,msgtype 表示消息类型。

curl 'https://bot-admin.minapp.xin/api/send?secret=#{secret}&conversation_id=#{conversation_id}' \

  -H 'Content-Type: application/json' \

  -d '

{

  "msgtype": "text",

  "text": {

    "content": "hello world"

  }

}'

1.1 文本


{

  "msgtype": "text",

  "text": {

    "content": "hello world"

  }

}

1.2 链接卡片


{

  "msgtype": "link",

  "link": {

    "title": "标题",

    "url": "https://x.com",

    "image_url": "https://x.com/logo.png",

    "desc": "描述"

  }

}

1.3 图片


{

  "msgtype": "image",

  "image": {

    "url": "https://tuiguangdashi.com/template/eyou/pc/skin/images/logo.png"

  }

}

1.4 小程序


{

  "msgtype": "miniprogram",

  "miniprogram": {}

}


2. 获取会话列表

2.1 获取用户会话

  • 接口地址:GET /api/users
  • 必填参数secret

https://bot-admin.minapp.xin/api/users?secret=#{secret}

  • 返回数据:包含用户名称和 conversation_id 的列表。

2.2 获取群组会话

  • 接口地址:GET /api/groups
  • 必填参数secret

https://bot-admin.minapp.xin/api/groups?secret=#{secret}

  • 返回数据:包含群组名称和 conversation_id 的列表。

3. Webhook 回调

  • 功能:后台填入 webhook 地址后,会收到所有会话信息通知。
  • 支持类型:文本、图片、小程序、链接。
  • 说明:每种消息类型字段不同,以 msgtype 区分。

3.1 文本消息


{

  "secret": "-",

  "msgtype": "text",

  "conversation_id": "",

  "sender": "",

  "text": {

    "content": ""

  }

}

3.2 图片消息


{

  "secret": "-",

  "msgtype": "image",

  "conversation_id": "",

  "sender": "",

  "image": {

    "cdn_type": "",

    "cdn": ""

  }

}

3.3 小程序消息


{

  "secret": "-",

  "msgtype": "miniprogram",

  "conversation_id": "",

  "sender": "",

  "miniprogram": {

    "appicon": "",

    "appid": "",

    "appname": "",

    "page_path": "",

    "title": ""

  }

}

3.4 链接消息


{

  "secret": "-",

  "msgtype": "link",

  "conversation_id": "",

  "sender": "",

  "link": {

    "title": "",

    "url": ""

  }

}