Skip to main content

概觀

Feed Generator 是在 Bluesky 上運作的「演算法 feed」機制。可依特定關鍵字或使用者條件公開自訂 feed。使用 laravel-bluesky,可在 Laravel 應用程式上輕鬆實作 Feed Generator。
官方教學:建立自訂 Feed
官方 starter kit:bluesky-social/feed-generator

註冊 FeedGenerator 演算法

最簡單的用法是在 AppServiceProvider::boot() 中以閉包註冊演算法。
name 請使用 URL 安全的字串。 演算法回傳值為包含 cursorfeed 的陣列。
套件會自動註冊所需的所有路由。
  • http://localhost/xrpc/app.bsky.feed.getFeedSkeleton?feed=at://did:web:example.com/app.bsky.feed.generator/artisan
  • http://localhost/xrpc/app.bsky.feed.describeFeedGenerator
  • http://localhost/.well-known/did.json
  • Service DID 會從目前的 URL 自動產生(例:did:web:example.com)。
你只需要決定 FeedGenerator 的 name 與實作內容而已。

公開 feed(建立指令)

僅在 Laravel 應用程式中實作 FeedGenerator 並不會發佈至 Bluesky。需建立呼叫 publishFeedGenerator 的指令並執行。
1

產生指令

2

實作指令

3

執行指令

成功後會在 Bluesky 個人資料的 feed 清單中新增連結。publishFeedGenerator 僅更新資訊,可重複執行多次。

建立多個 FeedGenerator

只要更換 name 並多次呼叫 register,即可建立多個 feed。
發佈指令中也同樣多次呼叫 publishFeedGenerator

分離演算法類別

使用獨立的類別取代閉包,可使程式碼更易整理。建立實作 FeedGeneratorAlgorithm contract 的 callable 類別,並於 AppServiceProvider 中註冊。

認證

官方 starter kit 的認證功能預設為啟用。若要停用,可將只回傳使用者 DID 的閉包傳入 validateAuthUsing
Feed 會受帳號的「語言設定」影響。若 FeedGenerator 已取得貼文但 Bluesky 上仍未顯示 feed,請檢查帳號的語言設定。

進階用法

透過 Artisan 指令與任務排程將貼文儲存至資料庫,演算法中只需從 DB 取得資料,即可實現無需呼叫 API 的高速 feed。
最後修改於 2026年8月2日