Post text + photos to personal Facebook timeline via Patchright stealth browser automation.
Facebook removed publish_actions permission in 2018. API cannot post to personal timelines.
Only browser automation works — this skill uses Patchright (stealth Chromium) to mimic human behavior.
cd scripts/ && pip install -r requirements.txt
python -m patchright install chromium
| Variable | Required | Description |
|---|---|---|
| ---------- | ---------- | ------------- |
FB_COOKIE_FILE | ✅ | Path to Facebook cookies JSON (Selenium format). Full account access. |
FB_STATE_FILE | ✅ | Writable path for Playwright state (default: /tmp/fb_state.json) |
FB_DRY_RUN | — | true (default) = preview only. false = actually post. |
FB_USER_AGENT | — | Override browser user agent |
facebook.com cookies as JSON via EditThisCookie extensionFB_COOKIE_FILE with chmod 600Cookies last ~30–90 days. Re-export when expired.
FB_COOKIE_FILE=~/.fb_cookies.json FB_DRY_RUN=false \
python3 scripts/fb_post.py -m "Hello from automation!"
FB_COOKIE_FILE=~/.fb_cookies.json FB_DRY_RUN=false \
python3 scripts/fb_post.py -m "Beautiful day!" -p photo1.jpg photo2.jpg
python3 scripts/fb_post.py -m "Test post" -p photo.jpg
# No actual posting — previews the flow
Use the built-in browser tool — already proven working for personal timeline posting:
# Step 1: Navigate to Facebook
browser(action="navigate", url="https://www.facebook.com/")
# Step 2: Confirm on personal profile (url should be facebook.com/me)
# Step 3: Click "What's on your mind"
browser(action="act", kind="click", ref="[post input box]")
# Step 4: Type message
browser(action="act", kind="type", text="Your message here")
# Step 5: Upload photo (if needed)
browser(action="upload", paths=["/path/to/photo.jpg"])
# Step 6: Set sharing to Public
# Step 7: Click Post button
browser(action="act", kind="click", ref="[post button]")
snapshot 找當前可用的 refbrowser(action="upload") 功能FB_DRY_RUN=false for live postingchmod 600 — never committed to git共 1 个版本