Post as a Page

This guide explains how to publish a post, comment and reply to posts and comments on your Facebook Feed as the Page.

Before You Start

You will need:

Publish a Post

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

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

On success, your app receives the following response:

{
  "id": "{page-post-id}" 
}

The post is published immediately.

See Also

Publish a Link

Send a POST request to the /{page-id}/feed endpoint and include the link parameter:

curl -i -X "POST https://graph.facebook.com/{page-id}/feed
  ?message=Smart video calling to fit every family
  &link=https://portal.facebook.com/products/
  &access_token={page-access-token}"

On success, your app receives the following response:

{
  "id": "{page-post-id}"
}

Publish a Photo

Send a POST request to /{page-id}/photos endpoint:

curl -i -X "POST https://graph.facebook.com/{page-id}/photos
    ?url={path-to-photo}
    &access_token={page-access-token}"

On success, your app receives the following response:

{
  "id":"{photo-id}",                        
  "post_id":"{page-post-id}"    
}

See Also

Publish a Video

Additional Requirements

Send a POST request to /{page-id}/videos endpoint:

curl -i -X POST "https://graph.facebook.com/{page-id}/videos"    

On success, your app receives the following response:

{
  "id":"{video-id}"   
}

See Also

Get the URL of a Page Post

To get the URL of a Page post, or permalink, simply append the post ID to https://www.facebook.com/.

https://www.facebook.com/{post-id}

This URL will redirect the person to the post URL.

Create an Unpublished Post

Send a POST request to the /{page-id}/feed endpoint with the published parameter set to false:

curl -i -X POST "https://graph.facebook.com/{page-id}/feed
  ?published=false
  &message=An unpublished post
  &access_token={page-access-token}"

On success, your app receives the following response:

{
  "id": "{page-post-id}"  
}

Your app should save the id to be used later to publish the content.

Publish an Unpublished Post

Send a POST request to /{page-post-id} endpoint with the published parameter set to true:

curl -i -X POST "https://graph.facebook.com/{page-post-id}
  ?is_published=true

On success, your app receives the following response:

{
  "success" : true
}

Schedule a Page Post

Send a POST request to the /{page-id}/feed endpoint with the published parameter set to false and the scheduled_publish_time parameter set to the timestamp in any of the following formats:

  • An integer UNIX timestamp [in seconds] (e.g. 1530432000).
  • An ISO 8061 timestamp string (e.g. 2018-09-01T10:15:30+01:00).
  • Any string otherwise parsable by PHP's strtotime() (e.g. +2 weeks, tomorrow)*.

Note, if you are relying on strtotime()'s relative date strings you can read-after-write the scheduled_publish_time of the created post to make sure it is what is expected.

curl -i -X POST "https://graph.facebook.com/{page-id}/feed
  ?published=false
  &message=A scheduled post
  &scheduled_publish_time={unix-time-stamp-of-a-future-date}"

On success, your app receives the following response:

{
  "id": "{page-post-id}"   
}  

Update a Post

Send a POST request to the /{page-post-id} endpoint with the message parameter set to the new text:

curl -i -X POST "https://graph.facebook.com/{page-post-id}
  ?message=I am updating my Page post.
  &access_token={page-access-token}"

On success, your app receives the following response:

{
  "success": true
}

Limitations

An app can only update a post if it was made using that app.

See Also

Delete a Post

Send a DELETE request to the /{page-post-id} endpoint:

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

On success, your app receives the following response:

{
  "success": true
}

Get Comments on a Page Post

Send a GET request to the /{page-post-id}/comments endpoint:

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

On success, your app receives the following response:

{
  "data": [
    {
      "created_time": "2020-02-19T23:05:53+0000",
      "from": {
        "name": "Kelly Visitor",
        "id": "{user-id}"
      },
      "message": "I published this comment on a Page post",
      "id": "{comment-id}"
    }
  ],
  "paging": {
    "cursors": {
      "before": "MQZDZD",
      "after": "MQZDZD"
    }
  }
}

Comment on a Post

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

curl -i -X POST https://graph.facebook.com/{page-post-id}/comments
  ?message=Nice post!
  &access_token={page-access-token}

On success, your app receives the following response:

{
  "id":"{comment-id}"  
}

Limitations

If a Page is unpublished no one will be able to comment on a Page post or comments. A Page can comment on a its own comments. If you try to comment as a User you will see a 1705 error.

{
  "error":{
    "message":"(#1705) There was an error posting to this wall",
    "type":"OAuthException", 
    "code":1705,
    "fbtrace_id":"HWxq+vf3HsQ"
  }
}