Posting as a Page

With the Pages API, people using your app can post to Facebook as a Page. For example, if a blog editor posts a new article on Facebook, it appears as an article for the blog, not the individual editor. People following the page will see the post in their Newsfeed.

The other key use cases for Facebook Pages are around marketing and advertising for a business using the Marketing API. For more information, see Ads Management API and Unpublished Page Posts

Prerequisites

Before someone can publish as a Page from your app, you need their Page access token and permission. For more information, see Page Access Tokens and Permissions.

Posting Content

Once your app has a Page access token and the right permissions, it can have a Page post a status update. The update appears in the Page's timeline. Your app should make requests to graph.facebook.com.

If your app has a Page post photos, the photos appear in the Page's timeline as well as the Page's photo album. Videos appear in the Page's timeline as well as the Pages | Videos tab.

After your app posts Page content, it can delete it or update it.

Text and Links

To post text to a Page's feed, provide a message parameter with the text along with the Page ID:

POST https://graph.facebook.com/546349135390552/feed?message=Hello fans
17  

On success, Graph API responds with JSON containing the Page ID and the ID for the post:

{
  "id": "546349135390552_1116689038356556"
}

To post a link, make a POST request. It can contain optional text in the message parameter:

POST https://graph.facebook.com/546349135390552/feed?message=For all Math geniuses :)&link=www.projecteuler.net

The response contains the Page ID and the post ID:

{
  "id": "546349135390552_1116691191689674"
}

Photos and Videos

When you post photos and videos to a page, you add them as edges to existing Graph API nodes. You can also add photos and videos to Users, Albums, Events and Groups.

For information on video uploads including limitations, supported formats and ways to upload, see Video Upload with Graph API.

To post a photo send a request to {page-id}/photos:

POST https://graph.facebook.com/546349135390552/photos  

On success, Graph API sends a JSON response with the photo ID and the post ID

{
  "id":"1116692661689527",
  "post_id":"546349135390552_1116692711689522"
}

To post a video, make a request to {page-id}/videos:

POST https://graph.facebook.com/546349135390552/videos    

Graph API sends this response on successful post with the video's object ID:

{
  "id":"1116696891689104"
}

As of Graph API 2.3, your app can post videos as a chunked, resumable upload. This enables you to upload larger videos and more easily handle upload errors and interruptions. For more information, see Graph API Advanced, Resumable Uploads.

To get a post's URL or permalink simply append the post ID to https://www.facebook.com/.

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

Calling this URL will redirect the user to the full post URL.

Example:

Assuming your post ID is 1557889584450800_1656388331267591, use the following URL to link to the post:

https://www.facebook.com/1557889584450800_1656388331267591

This will redirect the user to the post full URL:

https://www.facebook.com/permalink.php?story_fbid=1656388331267591&id=1557889584450800

Post Comments as Individual

There may be cases where your app posts comments on a Page as an individual. To do this your app needs the publish_actions permission from the user and the user access token.

For instructions see Requesting Permissions and Generating Access Tokens.

Once your app has the token and permission, it makes this API call:

curl -F 'method=post' \
     -F 'message=Nice post!' \
     -F 'access_token={user_access_token}' \
   https://graph.facebook.com/546349135390552_1129650603727066/comments

On success, your app gets this response with the post id and id for the new comment:

{"id":"1129650603727066_1139628382729288"}

When you add a video to a page, you have option to display the video as the Page's featured video or add it to the Page's video playlist.

Publishing Content

When your app publishes content as a Page, you can post it immediately or at a later time. There are different types of Page posts:

  • Published Content - The default for publishing. This is content someone wants to immediately publish for a page.

  • Unpublished Content - Any content people want to prepare to post but will wait to make public. The main scenario for this is marketing and advertising content. See Ads Management, Unpublished Page Posts.

  • Scheduled Publication - Prepare and upload content to post then publish it at a scheduled time.

Create Un-published Content

To create content to publish at a later time, post the content with the parameter published=false to {page-id}/feed:

POST https://graph.facebook.com/546349135390552/feed?published=false&message=An unpublished post

On success, Graph API responds with the page id and post id:

{
  "id": "546349135390552_1116698655022261"
}

Your app should hold on to the two ids which you can use later to publish the the content by setting published=true:

POST https://graph.facebook.com/546349135390552_1116699718355488?is_published=true

After Graph API publishes the post, it returns a message:

{'success' : true}

Schedule Publication

The other option to publish content at a later time is to create the content and schedule the time to publish it:

POST https://graph.facebook.com/546349135390552/feed?
      published=false&
      message=An scheduled post&
      scheduled_publish_time=1429134465

Messaging as a Page

To send messages as a Page you need the page access token then you get the conversation threads for the Page. To get a list of threads:

curl -F 'access_token={page_access_token}'  \
              -F 'method=get'  \
              -F 'fields=id,updated_time'
           https://graph.facebook.com/546349135390552/conversations 

The response is an array containing all conversation threads:

{
  "data": [
    {
      "updated_time": "2015-07-14T18:46:21+0000",
      "id": "t_mid.1365102458740:c2dcf05b4d0eb69364"
    },
    {
      "updated_time": "2013-04-10T01:04:24+0000",
      "id": "t_msg.a60faddc885cb7e4671d86237d2987be86"
    } 
  ]
}

Use the thread id and provide the message parameter as a POST request:

curl -F 'access_token={page_access_token}'  \
         -F 'method=post'  \
         -F 'message=Hello Fan!'
      https://graph.facebook.com/v2.4/t_msg.a60faddc885cb7e4671d86237d2987be86/messages 

On success, the API returns the thread id and the message id:

{
  "id": "m_mid.1436900539062:099a93692eb8395716",
  "uuid": "mid.1436900539062:099a93692eb8395716"
}