Get Started

This document explains how to successfully call the Pages API to post to your Page.

Before You Start

You will need the following:

  • A Facebook Page. This can be an unpublished or published Page.
  • manage_pages permission
  • publish_pages permission
  • A Page access token requested from a person who is able to perform the CREATE_CONTENT task on the Page.

Step 1. Get Your Page ID

Send a GET request to /{user-id}/accounts endpoint:

curl -i -X GET "https://graph.facebook.com/{user-id}/accounts
     ?access_token={user-access-token}"

On success, your app will receive the following response:

{
  "data": [
    {
      "access_token": "{page-access-token-for-this-page}",
      "category": "Internet Company",
      "category_list": [
        {
          "id": "2256",
          "name": "Internet Company"
        }
      ],
      "name": "Name of this Page",
      "id": "{page-id}",
      "tasks": [
        "ANALYZE",
        "ADVERTISE",
        "MODERATE",
        "CREATE_CONTENT"
      ]
    },
...

This query will also return a Page access token for this Page.

Step 2. Post as a Page

Send a POST request to the /{page-id}/feed endpoint with the message field:

curl -i -X POST "https://graph.facebook.com/{page-id}/feed
  ?message=Hello World!
  &access_token={page-access-token}"

On success, your app will receive the following response:

{
  "id": "422575694827569_917077345377399"  // Page post ID
}

Visit your Facebook Page to view the post.

Step 3. Verify Your Post

Sending a GET request to the /{page-id}/feed endpoint:

curl -i -X GET "https://graph.facebook.com/{page-id}/feed
     ?access_token={page-access-token}"

On success, your app will receive the following response:

{
  "data": [
    {
      "created_time": "2020-03-25T17:33:34+0000",
      "message": "Hello World!",
      "id": "422575694827569_917077345377399"  
    },
...
  ]
}

Use the Graph Explorer

The Graph Explorer tool is a UI that allows you to experiment with Facebook APIs without adding code to your app or website. You can select permissions, get access tokens, test GET, POST, and DELETE methods, and get code snippets of these queries for Android, iOS, JavaScript, PHP, and cURL.

Note, you will need a Facebook App ID to use the Graph Explorer.

Step 1. Get Your Page ID

Select the manage_pages and publish_pages permissions, set the GET request to the /me/accounts endpoint in the query box, and click Submit.

Note, the pages_show_list permission will automatically be added when you add the manage_pages permission.

Click on the ID of your Page, displayed directly beneath the name of your Page, to move the ID to the query box.

Step 2. Post as a Page

Under the User or Page drop down menu, select the Page access token for your Page. Next, set the method to POST with a request to the /{page-id}/feed endpoint, then set the Params key to message and the value to your post text. Click Submit.

On success, the Graph Explorer will show the ID of the Page post.

Visit your Facebook Page to view the post.

Step 3. Verify Your Post

Send a GET request to the /page-id/feed endpoint.

On success, the Graph Explorer will display the time the post was created, the text of the post, and the ID of the Pagae post.