[英]Share website content with image on facebook
How can I share my website content to facebook? 如何将我的网站内容分享到Facebook?
I have already tried Sharer and Dialog , however those don't display pictures. 我已经尝试过Sharer和Dialog ,但是那些不显示图片。
My code: 我的代码:
function facebook_share(){
FB.init({
appId : '1884730308422253',
status : true,
xfbml : true,
version : 'v2.8'
});
FB.ui({
method: 'feed',
name: 'Come Listen to this Song',
link: 'http://192.168.0.100/catchthemyoung/student',
picture: 'http://192.168.0.100/catchthem/images/timeline/EPUQuotgRj.png',
caption: 'mywebsite.com',
description: 'msg',
message: 'msg'
},
// callback
function(response) {
if (response && !response.error_message) {
alert('Posting completed.');
} else {
alert('Error while posting.');
}
}
);
}
Please make sure your domain is register with your app id "1884730308422253" Please add app domain first with website add platform => choose website and add link https://developers.facebook.com/apps/XXXXXXXXXXXXX[Yourid]/settings/ 请确保您的域名已注册您的应用程序ID“1884730308422253”请首先添加应用程序域名网站添加平台=>选择网站并添加链接https://developers.facebook.com/apps/XXXXXXXXXXXXX[Yourid]/settings/
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function () {
FB.init({
appId: '889551921179700',
xfbml: true,
version: 'v2.8'
});
};
(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'));
</script>
<span id="share_button" class="fb-btn">
<div class="fb_icon"></div>
<span class="fb-share">
<i class="fa fa-facebook"></i> Share
</span>
</span>
<script type="text/javascript">
document.getElementById('share_button').onclick = function () {
FB.ui({
method: 'share',
display: 'popup',
caption: 'Your Title',
picture: 'Your picture',
description: 'Your description',
href: 'Your link',
}, function (response) {
});
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.