Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Facebook API: Posting a Status Update

Facebook API: Posting a Status Update

3

The Facebook API lets you post status updates (message, links, photos etc) to your timeline via the API. This is handy if you want to have automatic sharing in your application (assuming users have consented to it) to post uploaded photos, links etc. The concept is easier than Posting to a Page, which I’ve covered previously.

First off, you need to add the publish_stream permission to your app to allow automatic posting of text, links, or photos to the timeline. This is known as an ‘additional permission’ for Facebook Applications, which the user has the option of skipping when adding your application.

In order to post a status update to the timeline, we must make a POST call to the /{user_id}/feed API endpoint. For the logged in user, the endpoint we need is below. At the minimum, we need to include the message parameter and access_token.

If successful, Facebook will return an ID for the post, which is made up of your User ID and the ID for the post.

If you want to post images, links etc, you can include additional parameters in your API call. The following are just a few parameters you can use:

  • message – the text for the status update, e.g. “TGI Friday!”.
  • link – A URL to a website you want to link to
  • picture – URL of an image you want to include in the update
  • name – The name of the link attachment
  • caption – The caption of the link (appears beneath the link name)
  • description – The description of the link (appears beneath the link caption)

For example, if I wanted to post a link to this article, my data would look like:

You can see the created post by copying the ID returned in the call and going to:

The status update itself will look something like:

A full list of properties to use with the /feed API call can be found on Facebook’s Documentation for Feeds.

Facebook, Facebook Graph API, Tutorial

3 comments on “Facebook API: Posting a Status Update”

  1. Singham Lwowicz (@jura_123) says:
    July 11, 2014 at 11:08 AM

    Well, when only I formed the url like this:
    https://graph.facebook.com/user_Id/feed?message=this+is+a+test+message&method=post&access_token=… – it worked for me

    Reply
    • Niraj Shah says:
      July 15, 2014 at 3:44 PM

      Yes, this is an acceptable format too. It’s usually used by clients that do not support POST, PUT and DELETE commands.

      Reply
    • Angki Ang says:
      August 1, 2014 at 11:18 AM

      worked like a charm!

      thanks buddy!

      Reply

Leave a Reply to Angki AngCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Support Me

Buy Me a Coffee

PSN Profile

Tags

ACL Amazon Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache Backup Bug Command Line Cordova cPanel / WHM Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Firewall Flash Gadget Geolocation Google Nexus 5 Hacking HTML5 iOS JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio PS4 Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2025 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Privacy Policy