Reputation: 557
I've been using Facebook's Feed Dialog to let users on a site share content on their Facebook feed. On their feed there would be a picture that serves as a link to the page on my site, with some text below it (name, caption and description fields). All of these - picture, name, caption and description are now deprecated and stop working on July 17th. Is there any other way to achieve this functionality using a different method?
Upvotes: 14
Views: 12368
Reputation: 503
Currently (12/2019) you have to use the OG tags set in the URL for the share, so dynamically update the OG tags in your page based on the url...I recommend each object on your page have a url based on params passed in. See this FB bug for an explanation https://developers.facebook.com/support/bugs/1783400898620381/
Upvotes: 0
Reputation: 1035
You need to use the Open Graph actions method described at the bottom of this page here in the FB dev docs.
Trigger a Share Dialog using the FB.ui function with the share_open_graph method parameter to share an Open Graph story.
Try this within your code to specify a custom image, title, description or link on your FB shares:
// this loads the Facebook API
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
window.fbAsyncInit = function () {
var appId = '1937011929814387';
FB.init({
appId: appId,
xfbml: true,
version: 'v2.9'
});
};
// FB Share with custom OG data.
(function($) {
$('.fb_share_btn').on('click', function (event) {
event.preventDefault();
event.stopImmediatePropagation();
// Dynamically gather and set the FB share data.
var FBDesc = 'Your custom description';
var FBTitle = 'Your custom title';
var FBLink = 'http://example.com/your-page-link';
var FBPic = 'http://example.com/img/your-custom-image.jpg';
// Open FB share popup
FB.ui({
method: 'share_open_graph',
action_type: 'og.shares',
action_properties: JSON.stringify({
object: {
'og:url': FBLink,
'og:title': FBTitle,
'og:description': FBDesc,
'og:image': FBPic
}
})
},
function (response) {
// Action after response
})
})
})( jQuery );
Upvotes: 33