meta
Use meta for Meta Marketing API and Instagram workflows.
Fail closed: if required inputs are missing or any command fails, stop immediately and surface the error.
Install
Human-required auth bootstrap (must happen first)
- - Human creates a Meta app and provides
APP_ID and APP_SECRET. - Human configures OAuth redirect allowlist in Meta Developer settings with the exact
REDIRECT_URI. - Redirect must resolve to the AI host callback endpoint. For a local AI host:
-
cloudflared tunnel --url http://127.0.0.1:53682 (or similar, it must be HTTPS)
- Set
REDIRECT_URI=https://<tunnel-domain>/oauth/callback
- - AI runs setup without auto-opening a local browser:
-
meta auth setup --profile <PROFILE> --app-id <APP_ID> --app-secret <APP_SECRET> --redirect-uri <REDIRECT_URI> --mode both --scope-pack solo_smb --listen 127.0.0.1:53682 --timeout 180s --open-browser=false
- - Human opens returned
auth_url on their own machine, logs in, and grants consent. - OAuth redirect lands on the AI host and token exchange completes there.
- Validate immediately:
- INLINECODE10
Common commands
- - Schema sync (recommended before writes): INLINECODE11
- Accounts list: INLINECODE12
- Graph read: INLINECODE13
- Campaign dry-run: INLINECODE14
- Campaign create: INLINECODE15
- Campaign budget update: INLINECODE16
- Insights run: INLINECODE17
- IG publish feed: INLINECODE18
Rules
- - Never invent IDs, profile names, paths, redirect URIs, or payload fields.
- Require explicit confirmation before budget-changing mutations.
- Prefer machine-readable output (
--output json or --format jsonl) for automation. - Redact secrets (
APP_SECRET, access tokens) when echoing commands/results.
meta
使用 meta 进行 Meta 营销 API 和 Instagram 工作流操作。
故障关闭:如果缺少必需的输入或任何命令失败,立即停止并显示错误。
安装
- - go install github.com/bilalbayram/metacli/cmd/meta@latest
- meta --help
需要人工操作的认证引导(必须首先执行)
- - 人工创建 Meta 应用并提供 APPID 和 APPSECRET。
- 人工在 Meta 开发者设置中配置 OAuth 重定向白名单,使用精确的 REDIRECT_URI。
- 重定向必须解析到 AI 主机回调端点。对于本地 AI 主机:
- cloudflared tunnel --url http://127.0.0.1:53682(或类似方式,必须为 HTTPS)
- 设置 REDIRECT_URI=https://<隧道域名>/oauth/callback
- meta auth setup --profile
--app-id ID> --app-secret SECRET> --redirect-uri URI> --mode both --scope-pack solosmb --listen 127.0.0.1:53682 --timeout 180s --open-browser=false
- - 人工在自己机器上打开返回的 auth_url,登录并授予权限。
- OAuth 重定向到达 AI 主机,令牌交换在此完成。
- 立即验证:
- meta auth validate --profile --min-ttl 72h
常用命令
- - 架构同步(建议在写入前执行):meta schema sync --schema-dir ~/.meta/schema-packs
- 账户列表:meta --profile insights accounts list --active-only --output table
- Graph 读取:meta --profile api get actACCOUNTID>/campaigns --fields id,name,status --limit 100 --follow-next
- 广告系列试运行:meta --profile campaign create --account-id ACCOUNTID> --params name=,objective=OUTCOMESALES,status=PAUSED --schema-dir ~/.meta/schema-packs --dry-run
- 创建广告系列:meta --profile campaign create --account-id ACCOUNTID> --params name=,objective=OUTCOMESALES,status=PAUSED --schema-dir ~/.meta/schema-packs
- 更新广告系列预算:meta --profile campaign update --campaign-id ID> --params dailybudget=INMINORUNITS> --confirm-budget-change
- 运行洞察分析:meta --profile insights run --account-id ACCOUNTID> --date-preset last7d --level campaign --metric-pack quality --format jsonl
- IG 发布动态:meta --profile ig publish feed --media-url MEDIAURL> --caption --idempotency-key KEY>
规则
- - 切勿编造 ID、配置文件名称、路径、重定向 URI 或负载字段。
- 在更改预算的变更操作前需要明确确认。
- 自动化操作优先使用机器可读输出(--output json 或 --format jsonl)。
- 在回显命令/结果时对机密信息(APP_SECRET、访问令牌)进行脱敏处理。