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?
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 );