0

如何检测 FB OTHER 页面之类的点击事件?我在一个页面上登录,其他 id 页面有类似按钮。

FB.init({
    appId       : '8888888888', // App ID
    channelUrl  : 'http://channel.com',
    status      : true, // check login status
    cookie      : true, // enable cookies to allow the server to access the session
    xfbml       : true, // parse XFBML
});
FB.login(function(response) {
    if (response.status == 'connected') {
        var other_page_id = "333333333333";  
        FB.api('/me/likes/'+other_page_id, function(response) {
            // check already liked other_page on start...
        });
    }
});
FB.Event.subscribe('edge.create', function(response) {
    //user just clicked "like" on MY page (id=8888888888), but I need other_page_id (id=333333333333) click event...
});
4

1 回答 1

0

所以我知道你想如果用户喜欢另一个页面时喜欢另一个页面FB.Event.subscribe

window.fbAsyncInit = function () {
        FB.init({
            appId: 'XxXxXxXxXxXxX', // App ID
            status: true, // check login status
        });

        FB.Event.subscribe('edge.create',

        function (response) {
            console.log('Checking if you liked Coca-Cola :)!');

            FB.getLoginStatus(function (response) {
                if (response.authResponse) {
                    // logged in and connected user with Your APP
                    var user_id = response.authResponse.userID; // Get the user Id from oAuth response and give it a variable 
                    var page_id = "178568815531741"; // Coca-Cola Page ID

                    // Use FQL to get the user likes
                    var fql_query = "SELECT uid FROM page_fan WHERE page_id = " + page_id + "and uid=" + user_id; 
                    var the_query = FB.Data.query(fql_query); 

                    the_query.wait(function (rows) {

                        if (rows.length == 1 && rows[0].uid == user_id) {
                            // If user has liked the Page 
                            console.log('You like Coca-Cola');
                        } else {
                            // If user has not liked the Page  
                            console.log('You don\'t like Coca-Cola');
                        }
                    });

                } else {
                    // If Use has not connected with Your APP, You can show the show the a Login button! 
                    console.log('Login to My App');
                }
            });
        })

};
于 2013-11-08T20:13:24.783 回答