问题描述
我一直在使用 Facebook 的 Feed Dialog 让网站上的用户在他们的 Facebook Feed 上分享内容.在他们的供稿中,会有一张图片作为链接到我网站上的页面,下面有一些文本(名称、标题和描述字段).所有这些 - 图片、名称、标题和描述现在都已弃用,并于 7 月 17 日停止工作.有没有其他方法可以使用不同的方法来实现此功能?
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?
推荐答案
您需要使用本页底部描述的 Open Graph 操作方法 此处在 FB 开发文档中.
You need to use the Open Graph actions method described at the bottom of this page here in the FB dev docs.
使用 FB.ui 函数和share_open_graph 方法参数,用于共享 Open Graph 故事.
在您的代码中尝试此操作以在您的 FB 共享中指定自定义图像、标题、描述或链接:
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 );
这篇关于不推荐使用 Facebook 的 Feed 对话框中的“图片",我如何发布图片链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!