The Share dialog gives people the ability to publish an individual story to their timeline. 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.
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.
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
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!
The following are the parameters for the Share dialog.
Parameter | Description | Required? |
---|---|---|
| Your app's unique identifier. | Yes. Provided automatically when you use the SDK. |
| How the Share dialog is rendered.
| Yes. Provided automatically when you use the SDK. |
| 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 | No |
| The link to share. The default value is the current URL. | Required when you use the SDK. |
redirect_uri Deprecated | ||
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 desktop | false |
A response only occurs if the user is logged into your app using Facebook Login.
Parameter | Description |
---|---|
| An error message. |