切换主题
引用与卡片
以下接口支持 contact 和 group 目标。目标、受理和验证响应的基础字段见 发送目标与响应。
引用回复
POST /v2/messages/refer。用于回复一条已有消息,并保留可定位的引用。
| 字段 | 类型 | 说明 |
|---|---|---|
target | object | 必填,id 与原消息的 conversation.id 相同。 |
text | string | 必填,非空正文,最多 2048 UTF-8 字节。 |
reference.message_id | string | 必填,非零 uint64 十进制字符串,取源事件 message.id。 |
{3 项}
"target": {2 项},
"type": "contact",
"id": "filehelper"
},
"text": "补充说明",
"reference": {1 项}
"message_id": "9007199254740993"
}
}
使用原事件所属账号的端口。兼容请求使用以下字段。
{2 项}
"type": "sendReferText",
"data": {3 项}
"wxid": "filehelper",
"msg": "补充说明",
"msgId": "9007199254740993"
}
}
返回 message.type=reference_text、message.reference.message_id 和 retry_safe=false。当前账号或目标会话找不到消息时返回 404 reference_not_found,微信不允许引用时返回 422 reference_not_allowed。
网页分享卡片
POST /v2/messages/share 和 POST /v2/messages/share/validate。用于分享一个可点击的 HTTP(S) 网页。
| v2 字段 | sendShareUrl.data | 说明 |
|---|---|---|
target | wxid | 必填,收件人。 |
title | title | 必填,最多 768 UTF-8 字节。 |
description | content | 最多 2048 UTF-8 字节,兼容请求必填。 |
url | jumpUrl | 必填,网页 HTTP(S) 直链,最多 2048 字节。 |
app_id | app | 可选,wx 加 16 位十六进制。 |
thumbnail | path | 可选,HTTP(S) 图片直链,最多 2048 字节。 |
{5 项}
"target": {2 项},
"type": "contact",
"id": "filehelper"
},
"title": "服务说明",
"description": "点开查看",
"url": "https://example.com/",
"thumbnail": "https://example.com/cover.png"
}
兼容请求示例。
{2 项}
"type": "sendShareUrl",
"data": {5 项}
"wxid": "filehelper",
"title": "服务说明",
"content": "点开查看",
"jumpUrl": "https://example.com/",
"path": "https://example.com/cover.png"
}
}
响应 message 返回 type=share 及 title、description、url、app_id、thumbnail。
小程序卡片
POST /v2/messages/applet 和 POST /v2/messages/applet/validate。用于把指定小程序页面分享给联系人或群。
| v2 字段 | sendApplet.data | 类型和规则 |
|---|---|---|
target | wxid | 必填,收件人。 |
title、description | title、content | 字符串,最多 768 和 2048 字节。标题必填,兼容请求的描述必填。 |
username | gh | 必填,小程序原始 ID,gh_ 前缀,可加 @app。 |
page_path | jumpPath | 必填,相对页面路径,可含查询,最多 2048 字节。 |
app_id | app_id | 可选,wx 加 16 位十六进制。缺省时尝试从同账号收到的卡片补齐。 |
nickname | nickname | 可选,小程序名称,最多 256 字节。 |
icon_url | icon_url | 可选 HTTP(S) 图标直链。 |
thumbnail | path | 可选 HTTP(S) 图片直链或本机绝对路径。 |
version、service_type | 同名 | 可选 JSON 整数,0–2147483647。 |
{6 项}
"target": {2 项},
"type": "contact",
"id": "filehelper"
},
"title": "预约服务",
"username": "gh_example@app",
"page_path": "pages/index/index.html",
"app_id": "wx0123456789abcdef",
"thumbnail": "https://example.com/cover.png"
}
兼容请求示例。
{2 项}
"type": "sendApplet",
"data": {6 项}
"wxid": "filehelper",
"title": "预约服务",
"content": "打开预约页面",
"gh": "gh_example",
"jumpPath": "pages/index/index.html",
"app_id": "wx0123456789abcdef"
}
}
本地封面支持 1 B–4 MiB 单帧 PNG、JPEG 或 BMP,宽高各最多 4096,总像素最多 16,777,216。HTTP(S) 地址最多 2048 字节。
响应 message 中有 type=applet、title、username、page_path、app_id,另有 data.metadata_source=request|received_card。资料不足时返回 409 applet_metadata_required。需要真实小程序信息,示例标识为占位值。网络封面已在修复版 1.1.8-dev 实测手机显示与打开,本地封面的修复版手机端仍待补测。
音乐卡片
POST /v2/messages/music 和 POST /v2/messages/music/validate。用于分享可打开或播放的歌曲,播放取决于来源及权限。
| v2 字段 | sendMusic.data | 含义 |
|---|---|---|
target | wxid | 收件人。 |
title、artist | name、author | 歌名和歌手,各最多 768 UTF-8 字节。 |
app_id | app | 应用标识,wx 加 16 位十六进制。 |
url、audio_url、thumbnail_url | jumpUrl、musicUrl、imageUrl | 详情页、音频和封面直链,均为 HTTP(S),各最多 2048 字节。 |
全部字段必填。兼容请求示例。
{2 项}
"type": "sendMusic",
"data": {7 项}
"wxid": "filehelper",
"name": "示例歌曲",
"author": "示例歌手",
"app": "wx0123456789abcdef",
"jumpUrl": "https://example.com/song",
"musicUrl": "https://example.com/audio.mp3",
"imageUrl": "https://example.com/cover.jpg"
}
}
{7 项}
"target": {2 项},
"type": "contact",
"id": "filehelper"
},
"title": "示例歌曲",
"artist": "示例歌手",
"app_id": "wx0123456789abcdef",
"url": "https://example.com/song",
"audio_url": "https://example.com/audio.mp3",
"thumbnail_url": "https://example.com/cover.jpg"
}
响应 message 返回 type=music、title、artist、app_id。适用于提供链接的音频卡片。