Facebook Like - 浏览器刷新后不会跟踪喜欢

发布于 2024-12-06 03:56:42 字数 1469 浏览 0 评论 0原文

我正在我的一个网站中实施 Facebook 的“点赞”选项作为投票工具。用户将能够通过喜欢团队的个人页面来对特定团队进行投票。我有很多团队,出于某种原因,当我“喜欢”某些团队时,刷新我的浏览器,我的“喜欢”计数就会刷新,就好像我从未“喜欢”该页面一样。然而,在其他一些团队页面上,当我“喜欢”并刷新时,计数是准确的并保持跟踪。

我似乎找不到有效和无效的团队页面之间的区别。代码是相同的,但有些保留点赞计数,有些则不保留。我希望有人以前经历过这种情况?

以下是我使用的 HTML5 Like 选项:

<div class="votePanel">

    <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#appId=262057453824946&xfbml=1";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

    <div class="fb-like" data-send="false" data-layout="button_count" data-width="120" data-show-faces="false" data-font="arial"></div>

</div>

以下是我的 Open Graph 标签:

<meta property="og:title" content="My Page Title" />
<meta property="og:type" content="movie" />
<meta property="og:url" content="<% response.write("http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL")) %>" />
<meta property="og:image" content="PATHTOMYIMAGE" />
<meta property="og:site_name" content="Site Title" />
<meta property="og:admins" content="MYADMINID" />
<meta property="og:description" content="DESCRIPTIONHERE" />

I'm implementing Facebook's "Like" option in one of my websites as a voting tool. Users will be able to vote on a specific team by Liking the team's individual page. I have a number of teams and for some reason when I "Like" some of the teams, refresh my browser, my Like count refreshes as if I never "Liked" the page at all. However, on some of the other teams pages, when I "Like" and refresh, the count is accurate and keeps track.

I can't seem to find what is differentiating between the team pages that work and don't work. Code is identical but some keep the Like count and some don't. I was hoping someone may have experienced this before?

Below is the HTML5 Like option I used:

<div class="votePanel">

    <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#appId=262057453824946&xfbml=1";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

    <div class="fb-like" data-send="false" data-layout="button_count" data-width="120" data-show-faces="false" data-font="arial"></div>

</div>

Below are my Open Graph tags:

<meta property="og:title" content="My Page Title" />
<meta property="og:type" content="movie" />
<meta property="og:url" content="<% response.write("http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL")) %>" />
<meta property="og:image" content="PATHTOMYIMAGE" />
<meta property="og:site_name" content="Site Title" />
<meta property="og:admins" content="MYADMINID" />
<meta property="og:description" content="DESCRIPTIONHERE" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅笑依然 2024-12-13 03:56:42

啊,我已经用一些资源让它工作了。

首先,我使用 Facebook 调试器 检查我的开放图标签并确保它们有效。我注意到我的“赞”按钮需要管理员 ID。此外,在“调试器”页面上,您实际上可以演示“Like”按钮,如有必要,它会显示错误消息。

我收到消息:

“页面无法提供有效的管理员列表。它需要使用“fb:app_id”元标记指定管理员,或使用“fb:admins”元标记指定以逗号分隔的管理员Facebook 用户列表。”

我注意到我的 fb:admins 标签与 og:admins 混淆了。我把字母调换了,一切都解决了!

但是,我仍然不确定为什么我的一些页面在修复之前允许“赞”按钮工作。

Ah, I've got it working with a few resources.

First, I used Facebook's Debugger to check my open graph tags and make sure they were valid. I noticed that my Like button required an admin ID. Also, on the Debugger page you can actually demo your Like button and it will display an error message if necessary.

I received the message:

"The page failed to provide a valid list of administrators. It needs to specify the administrators using either a "fb:app_id" meta tag, or using a "fb:admins" meta tag to specify a comma-delimited list of Facebook users."

What I noticed was that I had my fb:admins tag mixed up with og:admins. I switched the letters up and all was fixed!

However, I'm still not sure why a few of my pages allowed the Like button to work prior to the fix.

夏日浅笑〃 2024-12-13 03:56:42

我以前也注意到我的网站上发生过这种情况。通常需要缺少或不正确的开放图标记。无论如何,它在某些页面上运行但在其他页面上运行却很奇怪。我也强烈建议使用调试器工具。它指出了哪里出了问题。

I've noticed this happen on my sites before too. There's usually a missing or incorrect open graph tag that's required. It's really strange how it works anyway on some pages but not others. I highly recommend using the debugger tool too. It points out what is wrong.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文