Documentation
¶
Overview ¶
Package parser implements the w_popularity Facebook adapter.
Reality check: the open web (logged-out) cannot scrape Facebook reliably. A vanilla `curl -A 'Mozilla/5.0' https://www.facebook.com/<h>/` either 302s to /login/?next=… or returns a tiny "Error" stub page. We do not even try the logged-out path anymore. Instead we offer two real routes:
Graph API v19 (primary, when Config.AccessToken is set). Requires a Page Access Token; user profiles do not expose counters to third-party tokens. See https://developers.facebook.com/docs/graph-api/reference/page/ for the field list.
camoufox via CDP (skeleton). When Config.CamoufoxURL is set we will eventually drive a headless camoufox over Chrome DevTools Protocol with a real session cookie. The wiring layer is present but the fetch is currently a stub — it errors with "camoufox path not implemented" so production callers fail loudly until somebody finishes the work.
If neither AccessToken nor CamoufoxURL is configured, FetchChannel / FetchRecentPosts return shared.ErrAuth with a hint pointing the operator at the two env vars.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// AccessToken is a Facebook Graph API Page Access Token. When empty, the
// parser falls through to the camoufox path. Source: env FACEBOOK_ACCESS_TOKEN.
AccessToken string
// HTTPClient lets callers inject a custom transport (tests, instrumentation,
// proxies). Default: &http.Client{Timeout: HTTPTimeout}.
HTTPClient *http.Client
// HTTPTimeout caps every outbound Graph API call. Default: 15s.
HTTPTimeout time.Duration
// UserAgent is sent on every Graph API request. Default: a w_popularity
// identifier — Graph does not particularly care, but it helps log triage
// on the FB side.
UserAgent string
// CamoufoxURL is the CDP endpoint (Playwright WebSocket URL, e.g.
// "ws://camoufox:3000"). When set and AccessToken is empty, FetchChannel
// attempts the camoufox path (currently stubbed). Source: env CAMOUFOX_URL.
CamoufoxURL string
// GraphAPIURL overrides the Graph API root. Test hook only — leave empty
// in production.
GraphAPIURL string
// APIVersion overrides the API version segment (e.g. "v19.0"). Default
// "v19.0".
APIVersion string
}
Config controls runtime behaviour.
type FacebookParser ¶
type FacebookParser struct {
// contains filtered or unexported fields
}
FacebookParser is the public entry point.
func New ¶
func New(cfg Config) *FacebookParser
New constructs a FacebookParser with sensible defaults.
func (*FacebookParser) FetchChannel ¶
func (p *FacebookParser) FetchChannel(ctx context.Context, handle string) (shared.ChannelSnapshot, error)
FetchChannel routes to Graph API when AccessToken is set, falls through to camoufox when CamoufoxURL is set, otherwise returns ErrAuth with a hint.
func (*FacebookParser) FetchRecentPosts ¶
func (p *FacebookParser) FetchRecentPosts(ctx context.Context, handle string, since time.Time) ([]shared.PostSnapshot, error)
FetchRecentPosts uses the Graph /{page-id}/posts endpoint when AccessToken is set. Camoufox fallback is a stub.
func (*FacebookParser) Platform ¶
func (p *FacebookParser) Platform() shared.Platform
Platform implements shared.Parser.