在头部添加这个,改变你的应用程序ID和Image
宽度和高度应该是相同og:image:width and og:image:height
<meta property="fb:app_id" content=" your facebookAppId " />
<meta property="og:title" content=" This is title of post " />
<meta property="og:url" content="http://www.example.com/a.jpg">
<meta property="og:image" content="http://www.example.com/a.jpg" />
<meta property="og:image:width" content="640" />
<meta property="og:image:height" content="442" />
<meta property="og:description" content=" This is description of post" />
而且这个代码可以帮助你
<div id="fb-root"></div>
<script src="https://connect.facebook.net/en_US/all.js"></script>
<script>
/********* Code for deleting facebook cache ************/
FB.api(
'/',
'POST',
{"scrape": "true", "id": "http://www.example.com/a.jpg"},
function (response) {
}
);
/********* Code for deleting facebook cache ************/
(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#xfbml=1&version=v2.7&appId=xxxxxxxxxxfacebookAppId";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-share-button" data-href="http://www.example.com/a.jpg" data-layout="button"></div>
非常感谢。尝试了你的代码,它的工作:D – user3064132
欢迎:) –