Facebook 發佈

了解如何連結 Facebook 粉絲專頁,並透過 Boring 發佈各式內容到 Facebook。

連結粉絲專頁

前置需求

連結步驟

  1. 在控制台按下 「Connect Facebook Page」
  2. 如尚未登入 Facebook,請先登入
  3. 選擇要連結的粉絲專頁
  4. 檢視並授予必要權限
    • pages_show_list:查看粉絲專頁列表
    • pages_read_engagement:讀取互動數據
    • pages_manage_posts:發佈與管理貼文
    • pages_read_user_content:讀取粉絲專頁內容
  5. 點擊 「Done」 完成授權

完成後,粉絲專頁會顯示在「Authorized Accounts」列表,包含:

權杖資訊

支援的內容類型

Facebook 透過 Boring 支援以下貼文型態:

類型 說明 媒體數量 範例
文字 純文字貼文 0 公告、狀態更新
照片 單張圖片貼文 1 產品照、活動海報
相簿 多張圖片貼文 2-10 活動花絮、步驟教學
影片 影片貼文 1 教學影片、產品示範

發佈範例

1. 純文字貼文

{
  "post": {
    "accountId": "your-facebook-page-account-id",
    "content": {
      "text": "Hello from Boring API! This is a text-only post.",
      "mediaUrls": [],
      "platform": "facebook"
    },
    "target": {
      "targetType": "facebook"
    }
  }
}

效果:在粉絲專頁發布一則純文字貼文。

2. 單張照片貼文

{
  "post": {
    "accountId": "your-facebook-page-account-id",
    "content": {
      "text": "Check out this amazing photo!",
      "mediaUrls": ["https://example.com/image.jpg"],
      "platform": "facebook"
    },
    "target": {
      "targetType": "facebook"
    }
  }
}

效果:附帶一張圖片與文字說明的貼文。

媒體規格

3. 相簿貼文(多圖)

{
  "post": {
    "accountId": "your-facebook-page-account-id",
    "content": {
      "text": "Here's a collection of our best moments!",
      "mediaUrls": [
        "https://example.com/photo1.jpg",
        "https://example.com/photo2.jpg",
        "https://example.com/photo3.jpg",
        "https://example.com/photo4.jpg"
      ],
      "platform": "facebook"
    },
    "target": {
      "targetType": "facebook"
    }
  }
}

效果:建立含多張圖片的相簿貼文。

相簿限制

4. 影片貼文

{
  "post": {
    "accountId": "your-facebook-page-account-id",
    "content": {
      "text": "Watch this incredible video!",
      "mediaUrls": ["https://example.com/video.mp4"],
      "platform": "facebook"
    },
    "target": {
      "targetType": "facebook"
    }
  }
}

效果:附帶影片與文字說明的貼文。

影片規格

API 請求格式

完整範例

import requests

API_URL = "https://boring.aiagent-me.com/v2/posts"
API_KEY = "boring_xxxxxxxxxxxxx"
ACCOUNT_ID = "your-facebook-page-account-id"

# 相簿貼文範例
post_data = {
    "post": {
        "accountId": ACCOUNT_ID,
        "content": {
            "text": "Summer collection 2025! 🌞",
            "mediaUrls": [
                "https://storage.example.com/summer1.jpg",
                "https://storage.example.com/summer2.jpg",
                "https://storage.example.com/summer3.jpg"
            ],
            "platform": "facebook"
        },
        "target": {
            "targetType": "facebook"
        }
    }
}

headers = {
    "boring-api-key": API_KEY,
    "Content-Type": "application/json"
}

response = requests.post(API_URL, headers=headers, json=post_data)
print(response.json())

成功回應

{
  "success": true,
  "message": "Post published successfully",
  "data": {
    "post_id": "123456789_987654321",
    "post_type": "album",
    "platform": "facebook",
    "page_name": "My Awesome Page",
    "photo_count": 3,
    "published_at": "2025-01-20T10:30:00Z"
  }
}

媒體 URL 要求

上傳媒體的方式

媒體 URL 必須符合:

推薦的媒體託管服務

測試媒體 URL

發佈前可使用 cURL 測試:

curl -I https://example.com/image.jpg

應該會得到類似以下結果:

HTTP/2 200
content-type: image/jpeg
content-length: 123456

疑難排解

常見錯誤

錯誤:「Invalid account_id」

錯誤:「Failed to download media」

錯誤:「Invalid media type」

錯誤:「Token expired」

最佳實務

  1. 先以純文字測試:確認流程無誤後再加入媒體
  2. 使用可靠的媒體託管:避免臨時或會過期的 URL
  3. 事前驗證媒體 URL:確保可下載且格式正確
  4. 維持精簡文案:Facebook 建議 1-2 個段落
  5. 採用高品質圖片:建議至少 1200x630
  6. 監控發佈紀錄:於控制台查看錯誤訊息

發佈歷史

在控制台查看所有 Facebook 貼文:

  1. 登入 Boring 控制台
  2. 捲動至 「Recent Posts」 區塊
  3. 需要時可依平台篩選

每筆紀錄會顯示:

速率限制

Facebook API 具備以下速率限制:

Boring 會妥善處理速率限制,一旦達到限制會回傳相應錯誤。

進階功能

管理多個粉絲專頁

你可以在同一個 Boring 帳號中連結多個粉絲專頁,每個專頁都有獨立的帳號 ID。

操作範例

  1. 連結粉絲專頁 A(帳號 ID:aaa-111
  2. 連結粉絲專頁 B(帳號 ID:bbb-222
  3. 使用 accountId: "aaa-111" 發佈至粉絲專頁 A
  4. 使用 accountId: "bbb-222" 發佈至粉絲專頁 B

跨平台同步發佈

可同時在 Facebook、Instagram、Threads 發佈相同內容:

accounts = [
    "facebook-page-account-id",
    "instagram-account-id",
    "threads-account-id"
]

for account_id in accounts:
    # 依平台調整內容
    post_data = create_post_data(account_id, platform)
    response = requests.post(API_URL, headers=headers, json=post_data)

下一步