This guide explains how to create and update a post or comment, reply to a post or comment, and delete a post or comment, on your Facebook Page Feed as the Page.
To publish a post on a Page, send a POST
request to the /{page-id}/feed
endpoint.
You will need the following:
CREATE_CONTENT
task on the Page that is being queriedcurl -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.
To publish a link on a Page, 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}" }
To publish a photo on a Page, 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}" }
To publish a video on a Page, 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}" }
To get a list of Page posts, send a GET
request to the /{page-id}/feed
endpoint.
For people who manage the Page being queried, you will need the following:
CREATE_CONTENT
, MANAGE
, or MODERATE
task on the Page that is being queriedFor people who do not manage the Page being queried, you will need:
curl -i -X GET "https://graph.facebook.com/{page-id}/feed ?access_token={access-token}"
On success, your app receives the following response:
{ "data": [ { "created_time": "2019-01-02T18:31:28+0000", "message": "This is my test post on my Page.", "id": "{page-post-id}" } ], ...
To get the URL for 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.
To create an unpublished Page post, send a POST
request to the /{page-id}/feed
endpoint with the published
parameter set to false
.
You will need the following:
CREATE_CONTENT
task on the Page that is being queriedcurl -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.
To publish an unpublished Page 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 &access_token={page-access-token}"
On success, your app receives the following response:
{ "success" : true }
To schedule a Page post to be published at a later time, 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:
1530432000
)2018-09-01T10:15:30+01:00
)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.
You will need the following:
CREATE_CONTENT
task on the Page that is being queriedcurl -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} &access_token={page-access-token}"
On success, your app receives the following response:
{ "id": "{page-post-id}" }
To update a Page post, send a POST
request to the /{page-post-id}
endpoint with the message
parameter set to the new text.
You will need the following:
CREATE_CONTENT
task on the Page that is being queriedcurl -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 }
An app can only update a post if it was made using that app.
To delete a Page post, send a DELETE
request to the /{page-post-id}
endpoint.
You will need the following:
CREATE_CONTENT
task on the Page that is being queriedcurl -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 }
To get the comments for a Page post, send a GET
request to the /{page-post-id}/comments
endpoint.
You will need the following:
pages_read_engagement
permission for comments posted by your Page pages_read_user_content
permission for comments posted by visitors to your Page (or the manage_pages
permission)MODERATE
task on the Page that is being queriedcurl -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" } } }
To comment on a Page post, send a POST
request to the /{page-post-id}/comments
endpoint with the message
field.
You will need the following:
pages_manage_engagement
permission for comments posted by your Page pages_read_user_content
permission for comments posted by your Page MODERATE
task on the Page that is being queriedcurl -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}" }
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" } }