javascript Facebook Like 按钮显示“确认”链接,但确认后仍然无法点赞

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8100669/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 02:17:08  来源:igfitidea点击:

Facebook Like button shows the "Confirm" link, but still cannot Like after confirming

javascriptfacebookfacebook-like

提问by Leo Jiang

About 90% of the time, when I click on the Like button on my website, the confirm link shows up. When I click confirm, the popup appears and I click "Like". However, the confirm link is still there and my Like was not counted. I clicked confirm multiple times, but it still does not work. I refreshed the page many times, and about 10% of the time, the confirm link never shows up and I can Like it normally.

大约 90% 的情况下,当我单击网站上的“赞”按钮时,会显示确认链接。当我点击确认时,弹出窗口出现,我点击“喜欢”。但是,确认链接仍然存在,我的赞没有被计算在内。我多次点击确认,但它仍然不起作用。我多次刷新页面,大约 10% 的时间,确认链接从未出现,我可以正常点赞。

I heard about the Facebook Linter (aka debugger). I "linted" my page and I still cannot Like it.

我听说过 Facebook Linter(又名调试器)。我“整理”了我的页面,但我仍然无法喜欢它。

Here's an example page: http://linksku.com/news/funny/i-like-steve-jobs-less-and-less-the-more-i-read-about-him/(the bottom portion is loaded in an iframe).

这是一个示例页面:http: //linksku.com/news/funny/i-like-steve-jobs-less-and-less-the-more-i-read-about-him/(底部加载一个 iframe)。

采纳答案by Abby

You haven't got the open graph namespace included in your html tag. That might cause weird behaviour. Try updating that to see if anything improves. An example of what it should look like:

您的 html 标签中没有包含开放图命名空间。这可能会导致奇怪的行为。尝试更新它,看看是否有任何改进。它应该是什么样子的一个例子:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://ogp.me/ns#"
      xmlns:fb="https://www.facebook.com/2008/fbml">

see documentation.

请参阅文档

回答by Sumit Gupta

It is because of link redirection. Suppose you are making the button to like the following link:

这是因为链接重定向。假设您要使按钮喜欢以下链接:

http://example.com/abc.php?product=100

http://example.com/abc.php?product=100

but when someone opens the above link by typing into the web browser, they get redirected to the following link (just giving an example)

但是当有人通过在网络浏览器中输入内容打开上述链接时,他们会被重定向到以下链接(仅举个例子)

http://example.com/abc/def

http://example.com/abc/def

So make sure you put the correct link which is to be liked in the like button. In other words, if you will put http://example.com/abc/defin the link button, it won't ask for Confirmation.

因此,请确保将要被点赞的正确链接放在“点赞”按钮中。换句话说,如果你http://example.com/abc/def输入链接按钮,它不会要求确认。

回答by Synxmax

Load Facebook SDK This Way

以这种方式加载 Facebook SDK

<script type="text/javascript">
    window.fbAsyncInit = function() {
        FB.init({ appId: '111111111111111', status: true, cookie: true, xfbml: true });
    };

    (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
    } ());

</script>