知道点击了facebook之类的按钮

Jan*_*rre 3 javascript facebook

我需要知道我的页面的访问者是否点击了"赞"按钮.使用此代码:

<fb:like href="[my_url]" layout="button_count" show_faces="false" width="20" font=""></fb:like>
Run Code Online (Sandbox Code Playgroud)

并包括来自facebook的脚本.我知道我可以用这个:

FB.Event.subscribe('edge.create', function(response) {
    //if the user click on Like
}
Run Code Online (Sandbox Code Playgroud)

但如果用户alredy喜欢我的网站,我怎么知道呢?我不想让他不喜欢和喜欢再次举办那次活动.

mpl*_*jan 6

http://unbound-media.com/facebook/how-to-tell-if-a-facebook-user-likes-your-facebook-application/

FB.Event.subscribe('auth.sessionChange', function(response) {
        if(response.session){
            //check to see if user is a fan of the page
            var query = FB.Data.query( 'select page_id from page_fan where uid='+response.session.uid+' and page_id ='+PAGE_ID);
            query.wait( function(rows) {
                if(rows.length){
                    //user already likes your page
                }else{
                    //user has not yet liked your page
                }
            });
        }else{
            //user has not yet logged in
        }
    });
Run Code Online (Sandbox Code Playgroud)

更新:

我个人用

<iframe src="http://www.facebook.com/plugins/like.php?app_id=...&amp;send=false&amp;layout=button_count&amp;width=50&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:21px;" allowTransparency="true"></iframe>
Run Code Online (Sandbox Code Playgroud)

我从这里得到的:http://developers.facebook.com/docs/guides/web/

无法从其所在的页面再次单击它