本文介绍了Facebook FB.Event.subscribe事件不起火:(的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的asp.net webforms页面上的用户使用这个Facebook插件点击喜欢按钮时,我试图弹出警报。不幸的是,按钮不显示:

I am trying to popup an alert when the user clicks the 'like' button using this Facebook plugin on my asp.net webforms page. Unfortunately the button does not show up:

页面:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <div id="Div1">
    </div>
    <script type="text/javascript">
        (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>
    <form id="form1" runat="server">
    <div>
        <div id="fb-root">
        </div>
        <fb:like href="www.goal.com" send="true" width="450" show_faces="true">
        </fb:like>
        <script src="http://connect.facebook.net/en_US/all.js"></script>
        <script>
            FB.init({
                status: true, // check login status
                cookie: true, // enable cookies to allow the server to access the session
                xfbml: true  // parse XFBML
            });
        </script>
        <script type="text/javascript">

            FB.Event.subscribe('edge.create',
    function (response) {
        alert('You liked the URL: ' + response); //this does not fire?
    });

        </script>
    </div>
    </form>
</body>
</html>


推荐答案

尝试以异步方式加载JavaScript,请参阅:或的示例代码。

Try to load your javascript asychronously, see: http://fbdevwiki.com/wiki/FB.init or http://developers.facebook.com/blog/post/530/ for sample code.

此外,您的FB.Init()缺少 oauth:true appID: xxxx ,oauth 2.0是强制性的。让我们知道如果它有效

Also, your FB.Init() is missing oauth: true and appID: xxxx, oauth 2.0 is mandatory. Let us know if it works.

这篇关于Facebook FB.Event.subscribe事件不起火:(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 07:11