wecomcli-manage-doc
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese企业微信文档管理
WeCom Document Management
是企业微信提供的命令行程序,所有操作通过执行wecom-cli命令完成。wecom-cli
管理企业微信文档的创建、读取和编辑。所有接口支持通过 或 二选一定位文档。
docidurlis a command-line program provided by WeCom, all operations are completed by executingwecom-clicommands.wecom-cli
Manage the creation, reading and editing of WeCom documents. All APIs support locating documents by either or .
docidurl调用方式
Invocation Method
通过 调用,品类为 :
wecom-clidocbash
wecom-cli doc <tool_name> '<json_params>'Invoke via , with the category as :
wecom-clidocbash
wecom-cli doc <tool_name> '<json_params>'返回格式说明
Return Format Description
所有接口返回 JSON 对象,包含以下公共字段:
| 字段 | 类型 | 说明 |
|---|---|---|
| integer | 返回码, |
| string | 错误信息,成功时为 |
当 不为 时,说明接口调用失败,可重试 1 次;若仍失败,将 和 展示给用户。
errcode0errcodeerrmsgAll interfaces return JSON objects, including the following public fields:
| Field | Type | Description |
|---|---|---|
| integer | Return code, |
| string | Error message, which is |
When is not , it means the API call failed, you can retry once; if it still fails, display and to the user.
errcode0errcodeerrmsgget_doc_content
get_doc_content
获取文档完整内容数据,只能以 Markdown 格式返回。采用异步轮询机制:首次调用无需传 ,接口返回 ;若 为 false,需携带该 再次调用,直到 为 true 时返回完整内容。
task_idtask_idtask_donetask_idtask_done- 首次调用(不传 task_id):
bash
wecom-cli doc get_doc_content '{"docid": "DOCID", "type": 2}'- 轮询(携带上次返回的 task_id):
bash
wecom-cli doc get_doc_content '{"docid": "DOCID", "type": 2, "task_id": "xxx"}'- 或通过 URL:
bash
wecom-cli doc get_doc_content '{"url": "https://doc.weixin.qq.com/doc/xxx", "type": 2}'参见 API 详情。
Get the full content data of the document, which can only be returned in Markdown format. Adopts asynchronous polling mechanism: No need to pass for the first call, the interface returns ; if is false, you need to call again with this until is true to return the full content.
task_idtask_idtask_donetask_idtask_done- First call (without passing task_id):
bash
wecom-cli doc get_doc_content '{"docid": "DOCID", "type": 2}'- Polling (carry the task_id returned from the last call):
bash
wecom-cli doc get_doc_content '{"docid": "DOCID", "type": 2, "task_id": "xxx"}'- Or via URL:
bash
wecom-cli doc get_doc_content '{"url": "https://doc.weixin.qq.com/doc/xxx", "type": 2}'See API Details.
create_doc
create_doc
新建文档(doc_type=3)或智能表格(doc_type=10)。创建成功返回 url 和 docid。
bash
wecom-cli doc create_doc '{"doc_type": 3, "doc_name": "项目周报"}'bash
wecom-cli doc create_doc '{"doc_type": 10, "doc_name": "任务跟踪表"}'注意:docid 仅在创建时返回,需妥善保存。创建智能表格时默认包含一个子表,可通过 查询其 sheet_id。
smartsheet_get_sheet参见 API 详情。
Create a new document (doc_type=3) or smart sheet (doc_type=10). Returns url and docid upon successful creation.
bash
wecom-cli doc create_doc '{"doc_type": 3, "doc_name": "项目周报"}'bash
wecom-cli doc create_doc '{"doc_type": 10, "doc_name": "任务跟踪表"}'Note: docid is only returned when creating, please keep it properly. A smart sheet contains one sub-sheet by default when created, you can query its sheet_id via .
smartsheet_get_sheetSee API Details.
edit_doc_content
edit_doc_content
用 Markdown 内容覆写文档正文。 固定为 (Markdown)。
content_type1bash
wecom-cli doc edit_doc_content '{"docid": "DOCID", "content": "# 标题\n\n正文内容", "content_type": 1}'参见 API 详情。
Overwrite the document body with Markdown content. is fixed to (Markdown).
content_type1bash
wecom-cli doc edit_doc_content '{"docid": "DOCID", "content": "# 标题\n\n正文内容", "content_type": 1}'See API Details.
典型工作流
Typical Workflow
- 读取文档 →
bash
wecom-cli doc get_doc_content '{"docid": "DOCID", "type": 2}',若 为 false 则携带 继续轮询
2. 创建新文档 →
task_donetask_idbash
wecom-cli doc create_doc '{"doc_type": 3, "doc_name": "文档名"}',保存返回的 docid
3. 编辑文档 → 先 get_doc_content 了解当前内容,再 edit_doc_content 覆写
- Read document →
bash
wecom-cli doc get_doc_content '{"docid": "DOCID", "type": 2}', if is false, continue polling with
2. Create new document →
task_donetask_idbash
wecom-cli doc create_doc '{"doc_type": 3, "doc_name": "文档名"}', save the returned docid
3. Edit document → First call get_doc_content to understand the current content, then call edit_doc_content to overwrite