gpt4 book ai didi

facebook-javascript-sdk - Facebook 调试器工具显示正确的标签,sharebutton 生成不同的结果

转载 作者:行者123 更新时间:2023-12-01 05:00:18 25 4
gpt4 key购买 nike

我已经按照我应该的方式设置了我的 og 标签。 Facebook 调试器工具显示正确的标签并生成正确的共享预览。然而,我网站上的分享按钮会产生不同的结果。它添加了一个带有标题的 h2 标题标签,并且没有摘要。

我的代码:

<meta property="og:title" content="Page-Title"/> 
<meta property="og:url" content="Page-URL"/>
<meta property="og:image" content="Page-Image"/>
<meta property="og:description" content="Page-Description" />

初始化facebook分享按钮
window.fbAsyncInit = function() {
FB.init({
xfbml : true,
version : 'v2.5'
});
};
(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'));

最佳答案

看起来您缺少类型元属性和按钮本身的 html。

它应该是:

<html>
<head>
<title>Your Website Title</title>
<!-- You can use Open Graph tags to customize link previews.
Learn more: https://developers.facebook.com/docs/sharing/webmasters -->
<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="http://www.your-domain.com/path/image.jpg" />
</head>
<body>

<!-- Load Facebook SDK for JavaScript -->
<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/sdk.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<!-- Your share button code -->
<div class="fb-share-button"
data-href="http://www.your-domain.com/your-page.html"
data-layout="button_count">
</div>

</body>
</html>

关于facebook-javascript-sdk - Facebook 调试器工具显示正确的标签,sharebutton 生成不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33690952/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com