medium
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesemedium — read & publish on Medium via your own cookies
medium — 通过自有Cookie在Medium上读写
Drives the user's real Medium account through the same internal web API the
site uses (Medium retired its public write API in 2023), authenticated by the
login cookie they captured with the ACE extension. No browser, no third-party
deps — just .
urllibThe connector injects the cookie jar as an env var:
- — a JSON array of cookies (
MEDIUM_COOKIES,sid,uid). Secret — never echo or print it. The CLI echoes thexsrfcookie as thexsrfheader on writes for you. If the captured jar has nox-xsrf-tokencookie (common), the CLI mints one automatically before writing, so publishes no longer fail with "Missing xsrf token".xsrf
通过Medium官网使用的内部Web API操作用户的真实Medium账户(Medium已于2023年停用其公开写入API),通过用户使用ACE扩展捕获的登录Cookie进行身份验证。无需浏览器,无需第三方依赖——仅使用。
urllib该连接器将Cookie Jar作为环境变量注入:
- — Cookie的JSON数组(
MEDIUM_COOKIES、sid、uid)。保密内容——绝不要回显或打印。 CLI会在写入操作时自动将xsrfCookie作为xsrf头回显。如果捕获的Jar中没有x-xsrf-tokenCookie(常见情况),CLI会在写入前自动生成一个,因此发布操作不会再因“缺少xsrf令牌”而失败。xsrf
CLI
CLI
The skill ships — self-contained, stdlib only.
scripts/medium.pysh
MED=$SKILL_DIR/scripts/medium.py
python3 $MED whoami # who is logged in
python3 $MED articles --limit 20 # my posts + clap/response stats
python3 $MED article <post-id> # one post's details此技能附带了——独立脚本,仅依赖标准库。
scripts/medium.pysh
MED=$SKILL_DIR/scripts/medium.py
python3 $MED whoami # 查看当前登录用户
python3 $MED articles --limit 20 # 查看我的帖子及鼓掌/回复统计
python3 $MED article <post-id> # 查看单个帖子的详细信息Verify the connection first
先验证连接
sh
python3 $MED whoamish
python3 $MED whoami→ {"user_id": "...", "name": "...", "username": "..."}
→ {"user_id": "...", "name": "...", "username": "..."}
On an auth error the cookie is expired — have the user reconnect at
<https://auth.acedata.cloud/user/connections>. Do **not** loop-retry.
如果出现身份验证错误,说明Cookie已过期——请用户重新连接至<https://auth.acedata.cloud/user/connections>。**不要循环重试。**Publishing — GATED (dry-run unless trailing --confirm
)
--confirm发布操作——受限制(除非末尾添加--confirm
,否则为试运行)
--confirmpublish######>```-*1.code[links](url)https://…--confirm--confirmsh
python3 $MED publish --title "Title" --content-file a.md # dry-run
python3 $MED publish --title "Title" --content-file a.md --draft-only --confirm # private draft
python3 $MED publish --title "Title" --content-file a.md --confirm # PUBLIC storyPublishing is Medium's multi-step editor flow (new-story → write deltas →
publish). stops at the draft (visible only at the user's
). Default to unless the user asked to go live.
--draft-only/me/stories/drafts--draft-onlypublish######>```-*1.代码[链接](url)https://…--confirm--confirmsh
python3 $MED publish --title "Title" --content-file a.md # 试运行
python3 $MED publish --title "Title" --content-file a.md --draft-only --confirm # 发布为私有草稿
python3 $MED publish --title "Title" --content-file a.md --confirm # 发布为公开故事发布操作遵循Medium的多步骤编辑器流程(新建故事→写入增量内容→发布)。会停留在草稿阶段(仅在用户的页面可见)。除非用户要求公开发布,否则默认使用。
--draft-only/me/stories/drafts--draft-onlyImages
图片处理
publish--no-rehost-imagespublish--no-rehost-imagesGotchas
注意事项
- This is the user's real Medium account. Confirm before any publish.
- Markdown→Medium conversion covers headings, quotes, fenced code, bullet/
numbered lists, images, and inline markups (bold/italic/code/links). Medium's
editor has no table element: a narrow markdown table renders as an aligned
monospace code block, while a wide one (long cells / URLs, which would wrap into
an unreadable grid) is rendered as per-row records — the first column bolded as
a lead-in, the remaining columns as bullets.
header: value - Medium sits behind Cloudflare; an occasional 403/429 is transient — the CLI auto-retries once after a short pause. A persistent 403 means the cookie is genuinely expired (reconnect).
- Never print — it is full account access.
MEDIUM_COOKIES - ToS: acts only on the user's own account with their own captured cookie.
- 操作的是用户的真实Medium账户。 在任何发布操作前请确认。
- Markdown转Medium格式支持标题、引用、围栏代码块、项目符号/编号列表、图片以及行内标记(粗体/斜体/代码/链接)。Medium编辑器没有表格元素:窄Markdown表格会渲染为对齐的等宽代码块,而宽表格(长单元格/URL,会换行成难以阅读的网格)会渲染为每行记录——第一列加粗作为引导,其余列显示为项目符号。
header: value - Medium位于Cloudflare之后;偶尔出现的403/429错误是暂时的——CLI会在短暂暂停后自动重试一次。持续出现403错误意味着Cookie确实已过期(需重新连接)。
- 绝不要打印——它拥有账户的完全访问权限。
MEDIUM_COOKIES - 服务条款:仅在用户自有账户上操作,使用用户自行捕获的Cookie。
Record the output
记录输出结果
After you successfully publish and obtain the live result URL, call the built-in
tool ONCE so the user can track this deliverable in My Outputs:
publish_artifactpublish_artifact(kind="article", channel="medium", title="<title>", url="<the REAL returned URL>", status="delivered")Use the real returned URL — never fabricate one. Call it once per published item,
only after delivery is confirmed; skip it (or use ) if publishing failed.
See .
status="failed"_shared/artifacts.md成功发布并获取到实时结果URL后,调用内置的工具一次,以便用户能在“我的输出”中跟踪此交付成果:
publish_artifactpublish_artifact(kind="article", channel="medium", title="<title>", url="<the REAL returned URL>", status="delivered")使用真实返回的URL——绝不要伪造。每个发布项仅调用一次,仅在确认交付成功后调用;如果发布失败,请跳过(或使用)。详见。
status="failed"_shared/artifacts.md