← Back to Blog

πŸš€ Automating Facebook Page Posting Using the Meta Graph API (2025 Full Guide)

This guide explains how to automate posting to a Facebook Page using the Meta Graph API, including setup, token generation, posting, deleting posts, and best practices. All sensitive values in this guide use safe placeholders.


πŸ” Overview

  • Platform: Facebook (Meta)
  • API: Graph API v22.0
  • Goal: Automate posting to your Facebook Page
  • Method: System User (long-lived automation account)
  • Difficulty: Easy–Moderate
  • Best For: Event posting, affiliate posting, alerts, scheduled content, bots

βœ… Requirements

Before you start, you must have:

  1. Meta Developer App β€” https://developers.facebook.com
  2. Meta Business Manager account β€” required for System User tokens
  3. A Facebook Page you manage
  4. A System User added inside Business Manager
  5. Permissions granted to the System User:
    • pages_manage_posts
    • pages_read_engagement
    • pages_show_list
    • public_profile

⭐ Step 1 β€” Create a System User

  1. Go to Business Settings β†’ Users β†’ System Users
  2. Click Add System User
  3. Choose a name β†’ Role = Admin
  4. Assign the System User to:
    • your Facebook Page
    • your Facebook App

This System User is what allows automated posting.


⭐ Step 2 β€” Generate a System User Token

Inside Business Settings β†’ System Users β†’ Select your system user:

  1. Click Generate Token
  2. Select your App
  3. Enable these scopes:
    • pages_manage_posts
    • pages_read_engagement
    • pages_show_list
    • public_profile

You will receive a 60-day renewable System User Token:

1234567890abcdefSYSTEMUSERTOKEN1234567890

πŸ”’ Keep this private β€” never store in GitHub.


⭐ Step 3 β€” Get Your Facebook Page ID

Find it in:

Business Settings β†’ Pages β†’ Select Page

Example:

123456789012345

You need this for every API request.


⭐ Step 4 β€” Fetch Your Page Access Token

Use the System User Token to request a Page Token:

πŸ“Œ cURL

curl -X GET \
"https://graph.facebook.com/v22.0/123456789012345?fields=access_token&access_token=1234567890abcdefSYSTEMUSERTOKEN1234567890"

Response:

{
  "access_token": "1234567890abcdefPAGEACCESSTOKEN1234567890",
  "id": "123456789012345"
}

Save the page_access_token. This is the token you actually use to post.


⭐ Step 5 β€” Post to the Facebook Page

πŸ“Œ cURL Example

curl -X POST "https://graph.facebook.com/v22.0/123456789012345/feed" \
-F "message=πŸŽ‰ New events are live this week!" \
-F "link=https://yourdomain.com/events" \
-F "access_token=1234567890abcdefPAGEACCESSTOKEN1234567890"

πŸ“Œ Python Example

import requests

PAGE_ID = "123456789012345"
PAGE_TOKEN = "1234567890abcdefPAGEACCESSTOKEN1234567890"

def post_to_facebook(message, link=None):
    url = f"https://graph.facebook.com/v22.0/{PAGE_ID}/feed"
    payload = {
        "message": message,
        "access_token": PAGE_TOKEN
    }

    if link:
        payload["link"] = link

    res = requests.post(url, data=payload)
    print(res.json())

post_to_facebook(
    message="πŸ“£ Don't miss this week's updates!",
    link="https://yourdomain.com/events"
)

This automatically generates a clickable preview card.


⭐ Step 6 β€” Delete a Facebook Post

Every successful post returns an ID like:

123456789012345_987654321098765

πŸ“Œ cURL

curl -X DELETE \
"https://graph.facebook.com/v22.0/123456789012345_987654321098765?access_token=1234567890abcdefPAGEACCESSTOKEN1234567890"

πŸ“Œ Python

import requests

POST_ID = "123456789012345_987654321098765"
PAGE_TOKEN = "1234567890abcdefPAGEACCESSTOKEN1234567890"

url = f"https://graph.facebook.com/v22.0/{POST_ID}"
res = requests.delete(url, params={"access_token": PAGE_TOKEN})
print(res.json())

⭐ Step 7 β€” Token Expiration & Refreshing

  • Tokens last 60 days
  • To renew:
    1. Generate a new System User Token
    2. Fetch a new Page Token using the same API call
  • Automate renewal every 55 days to be safe

⭐ Step 8 β€” Security Best Practices

  • Store tokens in environment variables (.env files)
  • Never commit tokens to GitHub
  • Restrict access to servers that run posting scripts
  • Use HTTPS links for best preview rendering

⭐ Step 9 β€” Common Automation Use Cases

  • βœ”οΈ Auto-posting events
  • βœ”οΈ Affiliate link previews
  • βœ”οΈ Scheduled promotions
  • βœ”οΈ Auto-sharing blog posts
  • βœ”οΈ Marketplace bots
  • βœ”οΈ Ticketing websites
  • βœ”οΈ Announcement systems

πŸŽ‰ Final Notes

By using a System User + Page Access Token, you get the most stable, long-lived, automation-friendly way to publish content to Facebook.

If you have questions, spot something that changed in the Meta docs, or just want to share how you're using this setup, feel free to reach out at hello@rmalek.com.