0

This code is totally from FB Development tutorial. In my html file:

<script>
window.fbAsyncInit = function() {
        FB.init({
            appId      : 'APP_ID', // App ID
            channelUrl : '//WWW.localhost:3000//channel.html', // Channel File
            status     : true, // check login status
            cookie     : true, // enable cookies to allow the server to access the session
            xfbml      : true  // parse XFBML
        })};

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

    FB.Event.subscribe('edge.create',
            function(response) {
                alert('You liked the URL: ' + response);
            }
    );
</script>

As it is written in tutorial, Event subscribe should invoke alert each time button is clicked, but nothings happens. Basically, I want to start AJAX put each time button clicked and count likes

4

1 回答 1

0

事件订阅者应该在初始化程序中,APP_ID 应该是字符串,在 localhost 上测试需要删除 WWW:

window.fbAsyncInit = function() {
        FB.init({
            appId      : 'APP_ID', // App ID
            channelUrl : '//localhost:3000/channel.html', // Channel File
            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(response) {
                alert('You liked the URL: ' + response);
            }

 })};
于 2013-04-17T18:04:41.587 回答