[英]facebook share not adding image
I have facebook tabs app. 我有facebook标签应用程序。 and inside there I have share button 在里面,我有分享按钮
<p class="share-btn" id="button">share this</p>
<script>
(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>
<script>
window.fbAsyncInit = function () {
FB.init({
appId: 'app id',
cookie: true,
xfbml: true,
version: 'v2.8'
});
window.facebookShare = function (callback) {
var id = @Model.Id;
var options = ({
method: 'share',
href: 'https://www.facebook.com/my app url here&app_data=' + id
}),
status = '';
FB.ui(options, function (response) {
console.log(response);
if (response && !response.error_code) {
status = 'success';
$.event.trigger('fb-share.success');
} else {
status = 'error';
$.event.trigger('fb-share.error');
}
if (callback && typeof callback === "function") {
callback.call(this, status);
} else {
return response;
}
});
}
};
$('#button').on('click', function (e) {
e.preventDefault();
facebookShare(function (response) {
// simple function callback
//console.log(response);
});
});
// custom jQuery events
$(document)
.on('fb-share.success', function (e) {
window.location.href = "/Quiz/Finished";
})
.on('fb-share.error', function (e) {
//alert("fail");
});
</script>
this shares link ok but it is not adding thumbnail. 这共享链接确定,但未添加缩略图。 share looks this: 分享看起来是这样的:
But in my layout I have these: 但是在我的布局中,我有以下这些:
<meta property="og:url" content="http://www.your-domain.com/your-page.html" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Your Website Title" />
<meta property="og:description" content="Your description" />
<meta property="og:image" content="https://www.codeproject.com/KB/aspnet/AspnetPaths/SelectImage.png" />
how can I do that? 我怎样才能做到这一点? and is there any chance to pass image using options? 并且有机会使用选项传递图像吗?
You can try this tool with your URL 您可以通过网址尝试使用此工具
https://developers.facebook.com/tools/debug/ https://developers.facebook.com/tools/debug/
it will tell you the exact error. 它会告诉您确切的错误。
Greetings! 问候!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.