PublishService.PublishToWechatMp
发布到微信公众号
直接把 Markdown 或 HTML 内容发布到微信公众号——一站式完成正文预处理、封面上传、创建或更新草稿,并可选触发群发;适合 CLI 工具直接调用的场景。
Authentication
| 支持组合 | OAuth 2.0 | API Key |
|---|---|---|
| No identity | ||
| User identity | ||
| Org identity |
所需 scopes:creative:writecreative:publish
Request body · PublishToWechatMpRequest
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
title | string | — | 文章标题(必填)。 |
author | string | — | 文章作者。 |
digest | string | — | 文章摘要,未填写时微信默认截取正文前 120 字。 |
content | string | — | Markdown 或 HTML 正文内容(必填)。 |
image_map | object | — | 正文中的图片映射:本地路径/标识 → 已上传的微信图片 URL。 |
cover_url | string | — | 封面图 URL,将自动上传为微信 thumb 素材。 |
target | PublishToWechatMpTarget | — | 发布目标:草稿或群发。 |
template_id | string | — | 排版模板/主题 ID。 |
content_source_url | string | — | 原文链接 URL。 |
show_cover_pic | boolean | — | 是否在正文中显示封面图。 |
need_open_comment | boolean | — | 是否开启评论功能。 |
debug | boolean | — | 是否返回调试日志。 |
cached_articles | array<PublishedArticleInfo> | — | 客户端缓存的已发布文章(往期推荐功能的回退数据源)。 |
wechat_mp_credentials | WechatMpCredentials | — | 微信公众号 API 调用凭证(必填)。 详见 WechatMpCredentials 设计说明(types.proto)。 |
content_format | ContentFormat | — | 正文格式。未指定时按 Markdown 处理,以兼容旧客户端。 |
Response
200 OK · PublishToWechatMpResponse
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
ok | boolean | — | 操作是否成功。 |
message | string | — | 结果描述信息。 |
media_id | string | — | 草稿的 media_id。 |
debug_logs | array<string> | — | 调试日志(debug=true 时返回)。 |
published_articles | array<PublishedArticleInfo> | — | 拉取到的已发布文章列表(供客户端缓存)。 |
错误响应 · google.rpc.Status
非 2xx 响应均按 AIP-193 规范包装为google.rpc.Status,含 code /message /details 三段。details[].reason 是机器可读的具体错误原因码,可用于客户端分支处理。
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
code | integer (int32) | — | The status code, which should be an enum value of google.rpc.Code. |
message | string | — | A developer-facing error message. |
details | array<Any> | — | A list of messages that carry the error details. |
Examples
curl -X POST \
'https://api.appforges.com/v1/creative/wechat-mp/articles' \
-H 'Authorization: Bearer $ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"title": "string",
"author": "string",
"digest": "string",
"content": "string",
"image_map": {},
"cover_url": "string",
"target": "PUBLISH_TO_WECHAT_MP_TARGET_UNSPECIFIED",
"template_id": "string",
"content_source_url": "string",
"show_cover_pic": false,
"need_open_comment": false,
"debug": false,
"cached_articles": [
{
"title": "string",
"url": "string",
"publish_time": 0,
"category": "string"
}
],
"wechat_mp_credentials": {
"app_id": "string",
"app_secret": "string"
},
"content_format": "CONTENT_FORMAT_UNSPECIFIED"
}'OpenAPI spec v0.59.4 · synced 10/11/2026, 11:27:14 PM