[英]Facebook share button app doesn't show og data
我正在使用默認的Facebook分享按鈕來彈出一個窗口,以分享人們頁面上的鏈接。 但是,我的og數據沒有顯示。 它只是顯示默認數據。 這是我正在使用的頁面來源...
<html>
<head>
<meta property="og:title" content="here is a title" />
<meta property="og:url" content="http://www.trivialgaming.com/index.htm" />
<meta property="og:image" content="http://www.trivialgaming.com/bleh.jpg" />
</head>
<body>
<div id="fb-root"></div>
<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/all.js#xfbml=1&appId=424402201029167";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-share-button" data-href="https://www.trivialgaming.com/index.htm" data-type="button"></div>
</body>
</html>
將JavaScript SDK一次包含在您的頁面中,最好在開始標記之后。
用於JavaScript的Facebook SDK提供了一組豐富的客戶端功能,用於添加社交插件,進行API調用和實現Facebook登錄。
好的,嘗試將所有代碼組裝到以下這段代碼中,您可以使用這些代碼替換共享按鈕中包含的代碼:
<div id="fb-root"></div>
<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/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<li id="social_facebook">
<div class="social_action">
<div class="fb-share-button" data-href="http://shopmoonfall.bigcartel.com{{ product.url }}" data-type="button"></div>
</div>
</li>
<a title="Share on Facebook" href="javascript:void(0);" onClick="return share();" >Share with Facebook</a>
<script type="text/javascript">
function share()
{
FB.ui({ method: 'feed',
link: '//Link of the page',
picture: //image link,
name: 'Title',
caption: "//caption of the photo",
description: "//Description"
},function(response){
}
});
}
</script>
只需使用此代碼,然后將您的代碼放在有注釋的地方即可。
您不需要添加OG數據。 晚點再謝我。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.