Facebook Developers
DocsToolsSupportNewsApps
Log In
  • Social Plugins
  • Facebook Login
  • Open Graph
  • Facebook APIs
    • Graph API
    • FQL
    • Open Graph
    • Dialogs
    • Chat
    • Internationalization
    • Ads
  • Games
  • Payments
  • App Center
  • Promote Your App
  • iOS
  • Android
  • JavaScript
  • PHP
  • More SDKs
  • Dialogs
    • Add Page Tab Dialog
    • Feed Dialog
    • Friends Dialog
    • OAuth Dialog
    • Pay Dialog
    • Requests Dialog
    • Send Dialog

Feed Dialog

Facebook APIs › Dialogs › Feed Dialog

Overview

The Feed dialog prompts a person to publish an individual story to a profile's timeline, that is to share the story. This does not require any extended permissions.

Your app can also publish directly to a profile's timeline without interaction on the part of people using your app. To accomplish this, use the corresponding Graph API call.

JavaScript Example

The following simple JavaScript example demonstrates using the FB.ui method in the JavaScript SDK to use the Feed dialog:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:fb="https://www.facebook.com/2008/fbml">
  <head>
    <title>My Feed Dialog Page</title>
  </head>
  <body>
    <div id='fb-root'></div>
    <script src='http://connect.facebook.net/en_US/all.js'></script>
    <p><a onclick='postToFeed(); return false;'>Post to Feed</a></p>
    <p id='msg'></p>

    <script> 
      FB.init({appId: "YOUR_APP_ID", status: true, cookie: true});

      function postToFeed() {

        // calling the API ...
        var obj = {
          method: 'feed',
          redirect_uri: 'YOUR URL HERE',
          link: 'https://developers.facebook.com/docs/reference/dialogs/',
          picture: 'http://fbrell.com/f8.jpg',
          name: 'Facebook Dialogs',
          caption: 'Reference Documentation',
          description: 'Using Dialogs to interact with people.'
        };

        function callback(response) {
          document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
        }

        FB.ui(obj, callback);
      }

    </script>
  </body>
</html>

Note that the above example assumes that the person is already logged in and has authorized your app.

Direct URL example

Your app can also display a Feed Dialog by explicitly directing people to the /dialog/feed endpoint:

https://www.facebook.com/dialog/feed?
  app_id=458358780877780&
  link=https://developers.facebook.com/docs/reference/dialogs/&
  picture=http://fbrell.com/f8.jpg&
  name=Facebook%20Dialogs&
  caption=Reference%20Documentation&
  description=Using%20Dialogs%20to%20interact%20with%20users.&
  redirect_uri=https://mighty-lowlands-6381.herokuapp.com/

Click here to try the URL yourself. You should see a dialog that looks like the following:

If a person clicks Share, the browser redirects to

https://mighty-lowlands-6381.herokuapp.com/?post_id=12345

The published (or shared) story looks like this:

If a person clicks Cancel, the browser redirects to

https://mighty-lowlands-6381.herokuapp.com/

Note

If a person has the "Who can post on your timeline?" setting set to "Only me" and another person tries to make a post using the Feed dialog, it will display a "Cannot post" error.

Properties

app_id

Your app's identifier. Required, but automatically specified by most SDKs.

redirect_uri

The URL to redirect to after a person clicks a button on the dialog. Required, but automatically specified by most SDKs.

display

The display mode in which to render the dialog. The default is page on the www subdomain. display=wap is currently not supported. This is automatically specified by most SDKs.

from

The ID or username of the person posting the message. If this is unspecified, it defaults to the current person. If specified, it must be the ID of the person or of a page that the person administers.

to

The ID or username of the profile that this story will be published to. If this is unspecified, it defaults to the value of from.

link

The link attached to this post

picture

The URL of a picture attached to this post. The picture must be at least 50px by 50px (though minimum 200px by 200px is preferred) and have a maximum aspect ratio of 3:1

source

The URL of a media file (either SWF or MP3) attached to this post. If both source and picture are specified, only source is used.

name

The name of the link attachment.

caption

The caption of the link (appears beneath the link name). If not specified, this field is automatically populated with the URL of the link.

description

The description of the link (appears beneath the link caption). If not specified, this field is automatically populated by information scraped from the link, typically the title of the page.

properties

A JSON object of key/value pairs which will appear in the stream attachment beneath the description, with each property on its own line. Keys must be strings, and values can be either strings or JSON objects with the keys text and href.

actions

A JSON array containing a single object describing the action link which will appear next to the "Comment" and "Like" link under posts. The contained object must have the keys name and link.

ref

A text reference for the category of feed post. This category is used in Facebook Insights to help you measure the performance of different types of post

Return Data

post_id

The ID of the posted story, if the person chose to publish.

Updated 17 hours ago
Facebook © 2013 · English (US)
AboutAdvertisingCareersPlatform PoliciesPrivacy Policy