Facebook的|处理按钮点击

时间:2012-05-03 10:11:36

标签: facebook

我想处理Like按钮的用户点击。 我完全从Like button documentation page复制了生成的代码 页面,但每次我点击相似按钮,没有任何反应。

我已经阅读了与此问题相关的所有问题,但没有任何效果。 我知道这个问题已被多次询问,但这个问题让我发疯了。

我正在使用Firefox。

这是我的完整HTML:

<!doctype html>
<html xmlns:fb="http://ogp.me/ns/fb#">
<head>
    <meta charset="utf-8">
    <title>Facebook Like Button</title>
</head>
<body>
<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function () {
        FB.init({
            appId: 'MY_APP_ID', // App ID
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true  // parse XFBML
        });

        FB.Event.subscribe('edge.create', function () {
            alert('Like button is clicked');
        });
    };

    (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=MY_APP_ID";
        fjs.parentNode.insertBefore(js, fjs);
    } (document, 'script', 'facebook-jssdk'));
</script>


   <fb:like href="http://www.bluelink.ws/" send="true" layout="button_count" width="450" show_faces="true"></fb:like>


</body>
</html>

1 个答案:

答案 0 :(得分:1)

您已将My_APP_ID保留在示例中,它必须是实际的应用程序ID,而不是示例中的文本字符串。

还有值得在chrome / firefox打开JS控制台来监控错误/控制台消息。

并检查您在Facebook Linter中喜欢的网址:https://developers.facebook.com/tools/debug以检查您的网站OG标记

相关问题