Php 在哪里放置FB.Event.subscribe

Php 在哪里放置FB.Event.subscribe,php,javascript,facebook,Php,Javascript,Facebook,下面是我在我的网站上使用的类似Facebook的按钮(和共享按钮)的代码 它工作得很好。我点击Like按钮,砰的一声,我的Facebook账户的个人资料页面上出现了一个不错的通知。Facebook甚至自动生成一个预览图像,恰好是我网站的徽标。精彩的。我网站上的Like计数器总计正确 所以我想记录下点击Like按钮的次数。根据page,代码FB.Event.subscribe('edge.create',函数(response){})允许您执行此操作 在下面的代码中,我应该把代码FB.Event.

下面是我在我的网站上使用的类似Facebook的按钮(和共享按钮)的代码

它工作得很好。我点击Like按钮,砰的一声,我的Facebook账户的个人资料页面上出现了一个不错的通知。Facebook甚至自动生成一个预览图像,恰好是我网站的徽标。精彩的。我网站上的Like计数器总计正确

所以我想记录下点击Like按钮的次数。根据page,代码
FB.Event.subscribe('edge.create',函数(response){})允许您执行此操作

在下面的代码中,我应该把代码
FB.Event.subscribe('edge.create',function(response){}放在什么地方



我不完全确定这是否正确,但根据,您将事件订阅代码放在
FB.init()
之后和匿名函数调用之前

window.fbAsyncInit = function() {
    FB.init({
        appId  : 'sensored-app-id',
        status : true, // check login status
        cookie : true, // enable cookies to allow the server to access the session
        xfbml  : true  // parse XFBML
    });

    /* All the events registered */
    FB.Event.subscribe('comments.add', function (response) {
        // do something with response
        alert("comment added");
    });
};

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

此外,如果您看到,您将看到他将事件订阅代码也放在Facebook初始化代码之后。

没错:通常最容易在初始化之后立即放置所有事件订阅。这样你就不会错过任何东西。
window.fbAsyncInit = function() {
    FB.init({
        appId  : 'sensored-app-id',
        status : true, // check login status
        cookie : true, // enable cookies to allow the server to access the session
        xfbml  : true  // parse XFBML
    });

    /* All the events registered */
    FB.Event.subscribe('comments.add', function (response) {
        // do something with response
        alert("comment added");
    });
};

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