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 topicture
– URL of an image you want to include in the updatename
– The name of the link attachmentcaption
– 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.
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
Yes, this is an acceptable format too. It’s usually used by clients that do not support POST, PUT and DELETE commands.
worked like a charm!
thanks buddy!