threads-publishing-ruleslisted
Install: claude install-skill elrufaiforexfx22-creator/claudecode-video-maker
# Threads Publishing API 完整限制與排查指南
這份是基於實戰一整天的踩坑紀錄。所有「已知不通」「已知通」都有實測。
---
## 1. Token
### Scopes
發佈 post 需要兩個 scope:
- `threads_basic` — 讀自己資料(/me)
- `threads_content_publish` — 發 post(text / image / video / carousel)
### 生命週期(三段)
| 類型 | 取得方式 | 有效期 | 用途 |
|---|---|---|---|
| Short-lived | OAuth 流程結束直接給,或 Graph API Explorer 「Get User Access Token」 | **1 小時** | 馬上拿來換 long-lived,**不要直接拿來發 post** |
| Long-lived | `GET https://graph.threads.net/access_token?grant_type=th_exchange_token&client_secret=<APP_SECRET>&access_token=<SHORT>` | **60 天** | 實際用來發 post 的 |
| Refreshed long-lived | `GET https://graph.threads.net/refresh_access_token?grant_type=th_refresh_token&access_token=<LONG>` | 再 60 天 | 排程 cron 每 ~50 天跑一次,token 永不過期 |
### Token 失效的訊號
```json
{"error":{"message":"Failed to decode","type":"OAuthException","code":190,"fbtrace_id":"..."}}
```
意思:token 過期 / 格式錯 / 屬於別的 app。重新走 OAuth 流程拿新的 short-lived → exchange long-lived。
---
## 2. 三段式發佈流程
### Video / Image
```
1. POST /v1.0/me/threads
├─ media_type=VIDEO 或 IMAGE
├─ video_url=<HTTPS_URL> 或 image_url=<HTTPS_URL>
├─ text=<可選 caption>
└─ access_token=<LONG_LIVED>
→ 拿 creation_id
2. GET /v1.0/{creation_id}?fields=status,error_message
├─ status: IN_PROGRESS / FINISHED / ERROR / EXPIRED / PUBLISHED
├─ Video 通常 30 秒 ~ 3 分鐘
├─ Image 通常 < 5 秒
└─ 輪詢直到 FINISHED
3. POST /v1.0/me/threads_publish
├─ creation_id=<上面拿到的>
└─ access_token=<LONG_LIVED>
→ 拿 thread id,可選 GET 拿 permalink
```
### Text