我在FB上做了一个小应用,使用FB.ui允许用户在他们的墙上分享它。我希望分享的帖子在“评论”和“喜欢”旁边显示“分享”链接,就像任何普通的墙上帖子一样。
有没有办法用FB.ui做到这一点?
或者,是否有其他方法仍然允许我定义自定义图像、标题、描述等到墙上的帖子?
我当前的代码:
function share(name, description) {
FB.ui({
method: 'feed',
name: name,
picture: '/img/fb.png',
link: url,
caption: '',
message: '',
description: description
}, function() {
});
}发布于 2015-10-08 16:25:49
这可以用share_open_graph方法来完成。代码应如下所示
FB.ui({
method: 'share_open_graph',
action_type: 'og.shares',
action_properties: JSON.stringify({
object : {
'og:url': 'http://astahdziq.in/', // your url to share
'og:title': 'Here my custom title',
'og:description': 'here custom description',
'og:image': 'http://example.com/link/to/your/image.jpg'
}
})
},
// callback
function(response) {
if (response && !response.error_message) {
// then get post content
alert('successfully posted. Status id : '+response.post_id);
} else {
alert('Something went error.');
}
});发布于 2014-08-22 10:16:41
FB.ui({
method: 'share',
href: 'https://developers.facebook.com/docs/',
}, function(response){});要定义自定义图像、标题、描述,请在页面头部使用Open Graph Tags:
<meta property="og:url" content="http://samples.ogp.me/136756249803614" />
<meta property="og:title" content="Chocolate Pecan Pie" />
<meta property="og:description" content="This pie is delicious!" />
<meta property="og:image" content="https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/851565_496755187057665_544240989_n.jpg" />这样做的效果是:

发布于 2012-05-04 15:41:10
您必须使用操作属性,请参阅文档here
https://stackoverflow.com/questions/10444347
复制相似问题