getChat
获取聊天的详细信息。
请求
POST /:token/getchat
参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| chat_id | Integer/String | 是 | 目标聊天的唯一标识符或用户名 |
响应
返回 Chat 对象。
json
{
"ok": true,
"result": {
"id": -1001234567890,
"type": "supergroup",
"title": "技术交流群",
"username": "tech_group",
"first_name": null,
"description": "这是一个技术交流群组",
"permissions": {
"can_send_messages": true,
"can_send_media_messages": true,
"can_send_polls": true,
"can_send_other_messages": true,
"can_add_web_page_previews": true,
"can_change_info": false,
"can_invite_users": true,
"can_pin_messages": false
}
}
}返回字段说明
| 字段 | 类型 | 描述 |
|---|---|---|
| id | Integer | 聊天的唯一标识符 |
| type | String | 聊天类型,可选值:private、group、supergroup、channel |
| title | String | 群组或频道的标题,私聊时为空 |
| username | String | 聊天的用户名(如果设置了) |
| first_name | String | 私聊时对方的名字 |
| description | String | 群组或频道的简介描述 |
| permissions | ChatPermissions | 群组的默认成员权限 |
错误码
| 错误码 | 描述 |
|---|---|
| 400 | 请求参数错误,如 chat_id 格式不正确 |
| 401 | Token 无效或已过期 |
| 403 | Bot 不是该聊天的成员,无权获取信息 |
| 404 | 聊天不存在 |
| 500 | 服务器内部错误 |
示例
cURL
bash
curl -X POST "https://api.example.com/<token>/getchat" \
-H "Content-Type: application/json" \
-d '{
"chat_id": -1001234567890
}'