有谁知道如何创建Facebook分享按钮?我需要它是大约15-20像素高的水平版本。他们似乎放弃了任何文档,转而使用类似按钮,但我希望两者都有。我似乎只能找到wordpress插件,但我只需要代码片段。
任何帮助将不胜感激......谢谢你
格林 Roco服装
答案 0 :(得分:1)
如果你想使用javascript sdk:
window.fbAsyncInit = function () {
FB.init({ appId: appId, status: true, cookie: true,
xfbml: true
});
};
(function () {
var e = document.createElement('script');
e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
} ());
$("#Pst").click(function shareWithFacebook() {
FB.ui({ method: 'stream.publish',
message: 'message',
user_message_prompt: 'message',
attachment: {
name: 'message',
caption: 'message',
description: ('message'),
href: 'http://www.destination360.com/europe/sweden/images/s/sweden-visby.jpg',
media: [{ 'type': 'image', 'src': 'http://www.destination360.com/europe/sweden/images/s/sweden-visby.jpg', 'href': 'http://www.destination360.com/europe/sweden/images/s/sweden-visby.jpg'}]
},
action_links: [{ text: ' Name ', href: 'http://www.destination360.com/europe/sweden/images/s/sweden-visby.jpg'}]
},
function (response) {
if (response && response.post_id) {
// Do some custom action after the user successfully
// posts this to their wall
alert('Thanks for sharing!');
}
}
);
return false;
});
<div id="fb-root">
</div>
<a href="#" id="Pst" onclick="return shareWithFacebook();" >
Share
</a>
如果您想使用插件进行操作,请将其标记为已回答:): http://developers.facebook.com/docs/reference/plugins/like/
您会找到类似的代码:
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=137344766349901&xfbml=1"></script><fb:like href="www.eslamsoliman.uk.cm" send="true" width="450" show_faces="true" font=""></fb:like>
更改链接:)
答案 1 :(得分:0)
虽然仍然有效,但已弃用“共享”按钮。 目前推荐的通过网站实现共享的方式是Like button或Send button(通常也会与Like按钮配对,但可以单独使用)。
如果由于某种原因必须使用旧的共享按钮,开发人员站点上不再提供该文档,但这里有第三方示例:http://www.wpcode.net/add-share-button.html/(它应该适用于任何站点,而不仅仅是Wordpress博客)