切换主题
聊天记录、名片与位置
本页接口支持私聊和群聊。发送及验证响应的通用字段见 发送目标与响应。
合并聊天记录
POST /v2/messages/chatlog 和 POST /v2/messages/chatlog/validate。适用于把多条纯文本合并为一张可以点开的卡片。消息正文由调用方传入。
| v2 字段 | sendChatLog.data | 类型和规则 |
|---|---|---|
target | wxid | 必填,卡片收件人。 |
title | title | 必填,最多 768 UTF-8 字节。 |
items | dataList | 必填数组,1–50 条文本。 |
items[].sender_id | dataList[].wxid | 必填,发言人 ID,最多 128 字节,使用账号 ID。 |
items[].sender_name | dataList[].nickName | 必填,记录中展示的昵称,最多 256 字节。 |
items[].sender_avatar_url | dataList[].avatarUrl | 可选 HTTP(S) 头像直链,最多 2048 字节。缺省时从当前账号资料或联系人缓存补齐。 |
items[].timestamp | dataList[].timestamp | 必填 Unix 秒,1–2147483647。v2 用整数,兼容格式用十进制字符串。 |
items[].text | dataList[].msg | 必填,每条最多 2048 UTF-8 字节,全部正文最多 32768 字节。 |
{3 项}
"target": {2 项},
"type": "contact",
"id": "filehelper"
},
"title": "讨论摘要",
"items": [1 项]
{5 项}
"sender_id": "wxid_example",
"sender_name": "测试用户",
"sender_avatar_url": "https://example.com/avatar.png",
"timestamp": 1796176800,
"text": "第一行\n第二行"
}
]
}
兼容请求示例。
{2 项}
"type": "sendChatLog",
"data": {3 项}
"wxid": "filehelper",
"title": "讨论摘要",
"dataList": [1 项]
{4 项}
"wxid": "wxid_example",
"nickName": "测试用户",
"timestamp": "1796176800",
"msg": "第一条记录"
}
]
}
}
请求体最多 256 KiB。缺少头像资料时显示微信默认头像。响应的 message 有 type=chatlog、title 和整数 item_count。在 1.1.9-dev 上已验收单人和双发言人的头像、昵称及正文。
联系人名片
POST /v2/messages/card 和 POST /v2/messages/card/validate。适用于将一个联系人的公开资料发给另一位联系人或群聊。
| v2 字段 | sendCard.data | 说明 |
|---|---|---|
target | wxid | 必填,收件人。 |
contact_id | msg | 必填,被分享联系人的 wxid。 |
profile | profile | 必填,资料对象。 |
profile 字段 | 类型和限制 |
|---|---|
username | 必填字符串,须与 contact_id 一致,最多 128 字节。 |
nickname | 必填字符串,最多 256 字节。 |
bigheadimgurl、smallheadimgurl | 可选字符串,大头像和小头像,各最多 2048 字节。 |
alias、province、city | 可选字符串,微信号、省份和城市,各最多 128 字节。 |
fullpy、shortpy | 可选字符串,全拼和简拼,最多 256 和 64 字节。 |
sex、imagestatus、scene | 可选字符串,性别标记、头像状态和场景,最多 32、64 和 64 字节。 |
sign、regionCode | 可选字符串,签名和地区码,最多 1024 和 128 字节。 |
certflag | 可选 uint32 整数,认证标记。 |
certinfo、brandIconUrl、brandHomeUrl、brandSubscriptConfigUrl、biznamecardinfo | 可选字符串,认证说明、品牌图标、主页、订阅配置和业务名片信息,各最多 2048 字节。 |
brandFlags | 可选字符串,品牌标记,最多 256 字节。 |
{3 项}
"target": {2 项},
"type": "contact",
"id": "filehelper"
},
"contact_id": "wxid_example",
"profile": {2 项}
"username": "wxid_example",
"nickname": "示例联系人"
}
}
兼容请求示例。
{2 项}
"type": "sendCard",
"data": {3 项}
"wxid": "filehelper",
"msg": "wxid_example",
"profile": {2 项}
"username": "wxid_example",
"nickname": "示例联系人"
}
}
}
响应返回 message.type=card、contact_id、nickname、username。
位置
POST /v2/messages/location 和 POST /v2/messages/location/validate。用于发送可在微信里打开的静态地点卡片。
| 字段 | 类型 | 必填及范围 |
|---|---|---|
target | object | 必填,收件人。 |
x | string | 必填纬度,-90 到 90。 |
y | string | 必填经度,-180 到 180。 |
scale | string | 必填,0–100 的十进制整数。 |
label | string | 必填,地址,最多 512 UTF-8 字节。 |
poiname、poiid | string | 可选,地点名称和标识,各最多 256 字节。 |
{6 项}
"target": {2 项},
"type": "contact",
"id": "filehelper"
},
"x": "39.9087",
"y": "116.3975",
"scale": "15",
"label": "北京市东城区天安门广场",
"poiname": "天安门广场"
}
兼容请求示例。
{2 项}
"type": "sendLocationInfo",
"data": {2 项}
"wxid": "filehelper",
"xml": "<msg><location x='39.9087' y='116.3975' scale='15' label='天安门广场'/></msg>"
}
}
XML 提取上表的六个字段,额外资料忽略。响应 message.type=location,并返回这六个位置字段。