@post2all/cli

中文文档
0.4.0发布于 2026/11/02MITES Module构建来源已验证

post2all CLI

中文使用文档
文档目录10 节
  1. 安装和验证
  2. 配置文件
  3. 发现账户
  4. 连接和管理帐户
  5. 分析
  6. 创建文章
  7. 媒体
  8. 管理职位
  9. 主要标志
  10. 文档

post2all CLI

post2all REST API的官方命令行客户端。

安装和验证

pnpm add -g @post2all/cli
post2all config set-key   # prompts for the key; or: printf '%s' "$KEY" | post2all config set-key -
post2all config whoami

post2all config set-key <key> 仍然有效,但是在命令行上传递键将其存储在shell历史中;首选stdin或 POST2ALL_API_KEY 环境变量。写入配置文件 0600 内部的权限 0700 目录中。

凭据按以下顺序解析: --api-key, POST2ALL_API_KEY,然后 ~/.config/post2all/config.json.

检查已安装的版本 post2all --version. 在交互式命令中,CLI最多每24小时检查一次npm是否有更新的版本,并在有更新可用时打印一个更新命令。它从不自动安装更新,跳过检查 --json/非交互式使用,并且可以使用 POST2ALL_DISABLE_UPDATE_CHECK=1.

配置文件

业务和代理工作区可以将帐户和帖子组织到可选的配置文件中。业务支持2个配置文件;机构支持多达10个配置文件。

post2all profile list
post2all profile create "Acme" --external-id customer_123
post2all profile get prof_123 --json
post2all profile update prof_123 --name "Acme Inc."
post2all profile delete prof_123

使用一个命名的配置文件作为account/post命令的组织/过滤上下文,并使用全局选项:

post2all --profile-id prof_123 accounts --json
post2all --profile-id prof_123 posts --json

将现有帐户分配给概要文件或清除其概要文件分配。移动它会改变帐户在配置文件过滤列表中的显示位置;现有职位保持目标关系:

post2all account profile acc_123 prof_123
post2all account profile acc_123 --clear

发现账户

post2all constraints <accountId...> --json
post2all accounts --json
post2all account publishing-options acc_discord_123 --json

呼叫 constraints 编写之前一次加载每个平台限制和连接帐户的文本覆盖。在构造目标时使用返回的帐户ID和平台。每个帐户的发布选项只需要用于动态选择,例如Discord频道和TikTok隐私级别。

将发布选项视为文本、媒体和字段约束的真实来源。限制可以是特定于帐户的,例如,X付费层接收不同的文本限制。不要通过 --type. 成分是从附加介质推断出来的;混合图像/视频只允许当平台 media.allowMixedMedia 是真的。当 capability.media.altText 是现在,使用 --media 在每个媒体项上设置可选的Alt文本。X有意不公开该功能。

乳齿象的设置是 caption, mastodonVisibility (public, unlisted 安静的公共场所,或者 private 仅供追随者使用;默认为 public), contentWarning, sensitive (模糊附加媒体;图片和视频帖子)。每个服务器设置自己的字符限制(默认情况下为500个字符),模式以每个帐户为单位报告字符限制 capability.text.maxLength);链接计数为23个字符,内容警告计数为限制。最多可附上4张图片(每张8mb)或1段视频(40mb);图像和视频不能混合。已发布的帖子删除可用于乳齿象目标。

松弛设置是 caption, channelId (必需的;从 destinations 返回的 post2all account publishing-options <accountId>), unfurlLinks (默认为 true). 消息最多可容纳4,000个字符,最多可上传10个本地文件到工作空间(图片不超过20mb,视频不超过200mb,可自由混合)。公共频道立即发布;首先将post2all应用程序邀请到私人频道。已发布的帖子删除可用于Slack目标。

post2all post create \
  --content "Release notes are up: https://example.com/changelog" \
  --targets '[{"platform":"mastodon","accountId":"acc_mastodon_123","settings":{"mastodonVisibility":"unlisted","contentWarning":"Release notes","sensitive":false}}]' \
  --delivery now

TikTok需要后全管理媒体(capability.media.requiresManagedMedia):运行 post2all media upload (文件或 --url),并附上返回的资料 id;直接 url TikTok的目标媒体被拒绝。

连接和管理帐户

列出工作区当前可用的连接方法:

post2all account platforms

启动OAuth连接:

post2all account connect instagram \
  --redirect-url https://app.example.com/settings/social/complete

CLI打印提供程序授权URL和连接ID。在最终用户的浏览器中打开URL。用户直接与社交提供商一起登录并执行操作 不 需要post2all帐户或登录会话。

使用以下命令查看权威结果:

post2all account connection <connectionId>

其他生命周期命令:

post2all account get <accountId> --json
post2all account reconnect <accountId> --redirect-url https://app.example.com/settings/social/complete
post2all account disconnect <accountId>

Telegram打印bot用户名和短暂连接代码,而不是OAuth URL。Wircle使用 --api-key 和 --profile-handle.

乳齿象帐户位于独立的服务器上,因此传递帐户句柄(或仅传递服务器,例如 mastodon.social), --handle. 同样的旗帜也适用于 account reconnect:

post2all account connect mastodon \
  --handle [email protected] \
  --redirect-url https://app.example.com/settings/social/complete

要实现自动化,请添加 --json 并将post2all API密钥保存在可信后端/CLI主机上,而不是将其暴露给浏览器代码。

分析

阅读账户级分析:

post2all account analytics acc_instagram_123 --json
post2all account analytics acc_instagram_123 \
  --start-date 2026-08-01 \
  --end-date 2026-08-31

如果没有日期,post2all使用最近的30天(包括UTC天数);最长为90天。添加 --refresh 只有当你需要新的提供商数据,而不是缓存的分析。

比较提供商范围内的帖子:

post2all account analytics-posts acc_instagram_123 \
  --sort-by views \
  --sort-direction desc \
  --limit 20

结果可以包括直接在提供者上发布的内容。 origin=external 表示提供程序帖子与post2all帖子不匹配。

阅读post2all帖子的目标分析:

post2all post analytics post_abc --json

检查 analyticsStatus 对于每个目标;一个空的参数列表可能意味着不可用/没有数据/需要重新连接,而不是零粘性。

创建文章

CLI接受与REST API相同的目标结构:

post2all post create \
  --content "New release shipping today 🚀" \
  --targets '[
    {
      "platform": "discord",
      "accountId": "acc_discord_123",
      "settings": {
        "channelId": "1234567890",
        "autoCrosspost": true
      }
    },
    {
      "platform": "threads",
      "accountId": "acc_threads_123",
      "settings": {
        "caption": "A shorter Threads version",
        "topicTag": "buildinpublic"
      }
    }
  ]' \
  --delivery now

保存没有任何目标的不完整草稿:

post2all post create \
  --content "Work in progress" \
  --delivery draft

使用时区敏感的ISO时间戳安排帖子:

post2all post create \
  --content "Scheduled update" \
  --targets '[{"platform":"linkedin","accountId":"acc_linkedin_123","settings":{}}]' \
  --delivery scheduled \
  --scheduled-at "2026-07-20T09:00:00+05:30"

没有交付标志意味着 draft. 立即发布总是显式地使用 --delivery now.

在X, Instagram, Facebook, Threads, Bluesky或circle目标上添加第一条评论 settings.firstComment 还有一个可选的 settings.firstCommentDelaySeconds (0-86400,从目标发布开始计算)。检查 firstComment.available 每个帐户 post2all constraints <accountId...> --json 第一个;一个 false 值表示必须重新连接该帐户才能授予评论权限。

post2all post create \
  --content "Our new pricing is live." \
  --targets '[
    {
      "platform": "instagram",
      "accountId": "acc_instagram_123",
      "settings": {
        "firstComment": "Full breakdown: https://example.com/pricing",
        "firstCommentDelaySeconds": 120
      }
    }
  ]' \
  --delivery now

媒体

post2all media upload ./video.mp4 --json

post2all post create \
  --content "Product walkthrough" \
  --media '[{"id":"media_123","altText":"Product walkthrough showing the publishing workflow"}]' \
  --targets '[
    {
      "platform": "youtube",
      "accountId": "acc_youtube_123",
      "settings": {
        "title": "Product walkthrough",
        "privacyStatus": "unlisted"
      }
    }
  ]' \
  --delivery now

管理职位

post2all posts --status scheduled --limit 20 --json
post2all post get post_abc --json

post2all post update post_abc \
  --content "Updated copy" \
  --delivery scheduled \
  --scheduled-at "2026-07-21T10:00:00+05:30"

# Replace all destinations and settings
post2all post update post_abc \
  --targets '[{"platform":"linkedin","accountId":"acc_linkedin_123","settings":{}}]'

# Replace attached media and set per-media alt text
post2all post update post_abc \
  --media '[{"id":"media_456","altText":"Calendar view showing scheduled posts"}]'

post2all post cancel post_abc

# Inspect a post, then remove one published social post
post2all post get post_abc --json
post2all post delete-published post_abc --post-account-id post_account_1 --json

# Remove only the post2all record
post2all post delete post_abc

post get --json 包括 deletion.available 和 deletion.reason 每个目标。使用 post delete-published 只有在 deletion.available 是 true 用户确认破坏行为。私有rollout平台通过CLI仍然不可用。post2all post保持不变。

每个目标 post get --json 也有 firstComment.status (pending, sending, sent, failed, cancelled,或者 unknown). 重试 failed 注释或取消 pending 一:

post2all post first-comment-retry post_abc --post-account-id post_account_1 --json
post2all post first-comment-cancel post_abc --post-account-id post_account_1

post delete 从post2all中删除记录并取消任何挂起的计划。已经发布到社交平台的内容仍然存在。

草稿、计划、失败和部分失败的帖子可以在保留媒体可用的情况下更新。为更新提供的数组将替换其先前的值。

主要标志

国旗描述
--targets <json>PostTarget[] 包含 platform, accountId,以及特定于平台 settings
--delivery <mode>draft, now,或者 scheduled
--scheduled-at <iso>预定交货所需;必须包括 Z 或者显式偏移量
--media <json>托管的首选媒体阵列 id 或公共HTTPS url,加上可选的每项 altText
--media-ids <ids>的逗号分隔id的已弃用兼容性输入 media upload
--json返回机器可读的JSON

--status 的弃用别名 draft, scheduled, publish_now;新的集成应该使用 --delivery. 直接 url 媒体仍然由调用者管理,并且在发布/重试完成之前必须保持可访问。不要发送 --media 和 --media-ids 在一起。

当你想让post2all保留自己的副本时,在post2all托管的存储中导入一个临时/公共URL:

post2all media upload \
  --url "https://temporary.example.com/video.mp4" \
  --filename video.mp4

对于已经托管的稳定媒体,不需要导入:

post2all post create \
  --media '[{"url":"https://cdn.example.com/video.mp4","altText":"Product demo"}]' \
  --delivery draft

文档

版本与发布记录

@post2all/cli 共发布 32 个版本,首次发布于 2026/05/31;过去 12 个月发布了 32 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.0latest2026/11/021 天前
0.3.162026/10/295 天前
0.3.152026/10/286 天前
0.3.142026/10/1222 天前
0.3.132026/09/181 个月前
0.3.122026/09/171 个月前

关于 @post2all/cli 的常见问题

@post2all/cli 是什么?

post2all CLI

如何安装 @post2all/cli?

在项目目录运行 npm install @post2all/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 post2all,可以用 npx post2all 直接运行。

@post2all/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/post2all__cli 是否存在。

@post2all/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@post2all/cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@post2all/cli 可以商用吗?

@post2all/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@post2all/cli 还在维护吗?

最新版本 0.4.0 发布于 2026/11/02(1 天前);至今共发布 32 个版本,其中过去 12 个月发布了 32 个;首次发布于 2026/05/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。