我尝试从我的网站分享带有图像的帖子,但只有图像没有被共享,我检查了视图源上的 og:image 它出现在视图源上,但它没有出现在共享框和共享帖子上。
我也尝试过Facebook调试,但没有运气
页面链接:http://www.anothercrush.com/polling-detail/second-post
步骤:
-
填写 3 个字段并提交
-
现在,您可以在图像上方看到Facebook共享按钮,只需单击它即可
- 现在,您将在共享框上出现问题(空白框而不是图像)。
请找到解决方案
This code works for me you can try
<meta property="og:url" content="http://domain.com"/>
<meta property="og:title" content="PageTitle"/>
<meta property="og:description" content=" Description"/>
<meta property="og:image" content="image path"/>
<meta property="og:site_name" content="title" />
<meta property="fb:app_id" content="correct facebook app id"/>
脸书控制台 这对于检查您的链接Facebook控制台很有用
我在页面视图源中检查了您的元标记,但我没有找到 og:image 属性,如果您只传递这个 ?u= 那么其他将从 og 标签中获取,所以请按照这个或传递您想要的所有参数,如果您不传递其他参数,它将在页面中搜索首先找到的任何内容, 就像您的图像现在正在工作一样。
另一种分享和调用此方法的方法 shareOnFacebookUser() 在点击时
var appId='FACEBOOK_ID';
window.fbAsyncInit = function () {
// init the FB JS SDK
FB.init({
appId: appId, // App ID from the app dashboard
status: true, // Check Facebook Login status
xfbml: true // Look for social plugins on the page
});
};
// Load the SDK asynchronously
(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 = "https://connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function shareOnFacebookUser() {
var img = $("#image").val();
var link = $("#link").val();
var title = $("#name").val();
var desc = $("#desc").val();
FB.ui({
method: 'feed',
link: link,
name: title,
picture: img,
description:desc
}, function (response) {
if (response && response.post_id) {
}
else {
}
});
}