Share Dialog

The Share dialog gives people the ability to publish an individual story to their timeline, a friend's timeline, a group, or in a private message on Messenger. The Share dialog does not require Facebook Login or any extended permissions, so it is the easiest way to enable sharing on the web.

This documentation describes how to implement the Share dialog on the Web. To implement the Share dialog in a mobile app, see Sharing on iOS and Sharing on Android.

The following is an example of the Share dialog that is sharing a link to a user's timeline.

In the preceding image Share on your own Timeline is selected in the drop-down list for choosing the audience for the share. The drop-down list for choosing the audience for a share doesn't appear when a person is on a browser that is not logged in with a cookie. This is also true if the app uses the feed dialog instead of the share dialog or if the app uses iframe web view.

If you are the Webmaster for a page that is shared to Facebook, include open graph meta tags to customize the story that is shared back to Facebook. It's important that you mark up your website with Open Graph tags to take control over how your content appears on Facebook. For more information, see A Guide to Sharing for Webmasters.

Share by Using URL Redirection

To share a link by using URL redirection, use the following code. Line breaks are included for ease of reading. Remove the line breaks when you use this code.

https://www.facebook.com/dialog/share?
  app_id=145634995501895
  &display=popup
  &href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2F
  &redirect_uri=https%3A%2F%2Fdevelopers.facebook.com%2Ftools%2Fexplorer

Share by Using the Facebook SDK for JavaScript

The Share dialog is available in the Facebook SDK for JavaScript by using the FB.ui function with the share method parameter. Use the following code snippet to open the Share dialog.

FB.ui({
  method: 'share',
  href: 'https://developers.facebook.com/docs/',
}, function(response){});
Try it yourself!

Parameters

The following are the parameters for the Share dialog.

ParameterDescriptionRequired?

app_id

Your app's unique identifier.

Yes. Provided automatically when you use the SDK.

display

How the Share dialog is rendered.

  • URL Redirection – The display value is page. The Share dialog is a full page that appears within Facebook.com.

  • Facebook SDK for JavaScript – The display value is one of the following:

    • a modal iframe for people logged into your app
    • async when using within a game on Facebook.com
    • a popup window for everyone else

    If necessary, you can force the popup type when when you use the Facebook SDK for JavaScript.

  • Mobile Web Apps – The display value is always touch.

  • Facebook SDK for iOS or Android – The SDK specifies display automatically and chooses an appropriate display type for the device.

Yes. Provided automatically when you use the SDK.

hashtag

A hashtag to add to the shared content. People can remove the hashtag in the Share dialog. The hashtag should include the hash symbol, for example #facebook. The default value is null.

No

href

The link to share. The default value is the current URL.

Required when you use the SDK.

redirect_uri

Deprecated

The URL to redirect to after a person clicks a button on the Share dialog.Yes. Provided automatically when you use the SDK.
mobile_iframe

Deprecated

true to open the share dialog in an iframe on top of your website. This option is only available for mobile, not desktopfalse

Response Data

A response only occurs if the user is logged into your app using Facebook Login.

ParameterDescription

error_message

An error message.