wecomcli-smartpage
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese企业微信智能文档管理
WeCom Smart Document Management
是企业微信提供的命令行程序,所有操作通过执行wecom-cli命令完成。wecom-cli
资源型技能,负责智能文档(原名智能主页,)的创建与内容导出。
/smartpage/*is a command-line program provided by WeCom, and all operations are completed by executing thewecom-clicommand.wecom-cli
This is a resource-type skill responsible for creating and exporting Smart Documents (formerly known as Smart Homepage, ).
/smartpage/*调用方式
Calling Method
通过 调用,品类为 :
wecom-clidocbash
wecom-cli doc <tool_name> '<json_params>'Call via , with the category :
wecom-clidocbash
wecom-cli doc <tool_name> '<json_params>'返回格式说明
Return Format Description
所有接口返回 JSON 对象,包含以下公共字段:
| 字段 | 类型 | 说明 |
|---|---|---|
| integer | 返回码, |
| string | 错误信息,成功时为 |
当 不为 时,说明接口调用失败,可重试 1 次;若仍失败,将 和 展示给用户。
errcode0errcodeerrmsgAll interfaces return a JSON object containing the following public fields:
| Field | Type | Description |
|---|---|---|
| integer | Return code, |
| string | Error message, |
When is not , it means the interface call failed, and you can retry once; if it still fails, display and to the user.
errcode0errcodeerrmsg特殊错误码
Special Error Codes
| errcode | errmsg | 含义 | 处理方式 |
|---|---|---|---|
| | 文档品类与所调用的接口不匹配 | 确认目标 URL 为 |
| errcode | errmsg | Meaning | Handling Method |
|---|---|---|---|
| | The document category does not match the called interface | Confirm that the target URL is |
接口详述
Interface Details
创建智能文档
Create Smart Document
创建智能文档(原名智能主页),支持传入标题和多个子页面。每个子页面可指定标题、内容类型和本地文件路径。创建成功返回 和 。
docidurl特殊语法:此命令必须使用(带+smartpage_create前缀),加号不可省略;该+仅适用于此命令,不要泛化到其他+子命令。doc
命令
bash
wecom-cli doc +smartpage_create '<JSON 参数>'参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| string | 否 | — | 智能文档标题 |
| array | 是 | — | 子页面列表 |
| string | 否 | — | 子页面标题 |
| int | 否 | 1 | 内容类型:1-Markdown,0-Text(纯文本) |
| string | 否 | — | 子页面内容对应的本地文件路径 |
注意事项
- 必须与文件实际内容匹配:
content_type文件或包含 Markdown 语法的内容必须传.md,仅纯文本才传1。绝大多数场景应传0。1 - 仅在创建时返回,需妥善保存。
docid - 每个子页面的 Markdown 文件大小不得超过 10MB,超过会导致创建失败;如文件过大,需先拆分为多个子页面再创建。
- 智能文档还支持背景块()、分栏(
<card>)等扩展语法,详见 references/smartpage-create.md。<grid>
Create a Smart Document (formerly known as Smart Homepage), supporting the input of a title and multiple subpages. Each subpage can specify a title, content type, and local file path. Returns and upon successful creation.
docidurlSpecial Syntax: This command must use(with the+smartpage_createprefix), the plus sign cannot be omitted; this+only applies to this command, do not generalize it to other+subcommands.doc
Command
bash
wecom-cli doc +smartpage_create '<JSON parameters>'Parameters
| Parameter | Type | Required | Default Value | Description |
|---|---|---|---|---|
| string | No | — | Smart Document title |
| array | Yes | — | List of subpages |
| string | No | — | Subpage title |
| int | No | 1 | Content type: 1-Markdown, 0-Text (plain text) |
| string | No | — | Local file path corresponding to the subpage content |
Notes
- must match the actual content of the file:
content_typefiles or content containing Markdown syntax must pass.md, only plain text should pass1.0should be used in most scenarios.1 - is only returned during creation, please save it properly.
docid - The size of each subpage's Markdown file must not exceed 10MB, otherwise creation will fail; if the file is too large, split it into multiple subpages before creation.
- Smart Documents also support extended syntax such as background blocks () and columns (
<card>), see references/smartpage-create.md for details.<grid>
导出智能文档内容
Export Smart Document Content
获取智能文档的完整内容,导出为 Markdown。采用异步两步操作:先用 提交导出任务拿到 ,再用 轮询任务,直到 为 时返回 。
smartpage_export_tasktask_idsmartpage_get_export_resulttask_donetruecontent第一步:提交导出任务
bash
undefinedObtain the complete content of a Smart Document and export it to Markdown. Uses asynchronous two-step operation: first submit an export task with to get , then poll the task with until is , then return .
smartpage_export_tasktask_idsmartpage_get_export_resulttask_donetruecontentStep 1: Submit Export Task
bash
undefined通过 docid
Via docid
wecom-cli doc smartpage_export_task '{"docid": "DOCID", "content_type": 1}'
wecom-cli doc smartpage_export_task '{"docid": "DOCID", "content_type": 1}'
通过 url
Via url
wecom-cli doc smartpage_export_task '{"url": "https://doc.weixin.qq.com/smartpage/xxx", "content_type": 1}'
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| `docid` | string | 与 `url` 二选一 | — | 智能文档的 docid |
| `url` | string | 与 `docid` 二选一 | — | 智能文档的访问链接 |
| `content_type` | int | 是 | — | 导出内容格式,目前仅支持 `1`(Markdown) |
**第二步:轮询导出结果**
```bash
wecom-cli doc smartpage_get_export_result '{"task_id": "TASK_ID"}'| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| string | 是 | — | 由 |
使用规则
- 第一步获取 后,携带其调用第二步;若
task_id为task_done则继续轮询,直到false为task_done,返回的true字段即为完整 Markdown 内容。content
参见 API 详情。
wecom-cli doc smartpage_export_task '{"url": "https://doc.weixin.qq.com/smartpage/xxx", "content_type": 1}'
| Parameter | Type | Required | Default Value | Description |
|---|---|---|---|---|
| `docid` | string | Either `docid` or `url` is required | — | docid of the Smart Document |
| `url` | string | Either `docid` or `url` is required | — | Access link of the Smart Document |
| `content_type` | int | Yes | — | Export content format, currently only supports `1` (Markdown) |
**Step 2: Poll Export Result**
```bash
wecom-cli doc smartpage_get_export_result '{"task_id": "TASK_ID"}'| Parameter | Type | Required | Default Value | Description |
|---|---|---|---|---|
| string | Yes | — | Task ID returned by |
Usage Rules
- After obtaining in the first step, call the second step with it; if
task_idistask_done, continue polling untilfalseistask_done, and the returnedtruefield is the complete Markdown content.content
See API Details.
跨技能依赖
Cross-Skill Dependencies
| 依赖技能 | 典型协作场景 | 数据流向 |
|---|---|---|
| 用户要求把智能文档链接发给某人/某群 | 本 skill 创建后返回 |
| Dependent Skill | Typical Collaboration Scenario | Data Flow |
|---|---|---|
| User requests to send the Smart Document link to someone/some group | This skill returns |