簡體   English   中英

知道點擊了facebook之類的按鈕

[英]Know if facebook like button is clicked

我需要知道我的頁面的訪問者是否點擊了“贊”按鈕。 使用此代碼:

<fb:like href="[my_url]" layout="button_count" show_faces="false" width="20" font=""></fb:like>

並包括來自facebook的腳本。 我知道我可以用這個:

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

但如果用戶alredy喜歡我的網站,我怎么知道呢? 我不想讓他不喜歡和喜歡再次舉辦那次活動。

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
        }
    });

更新:

我個人用

<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>

我從這里得到的: http//developers.facebook.com/docs/guides/web/

無法從其所在的頁面再次單擊它

事實上可能是這樣的:

FB.login(function(response) {
  if (response.status == 'connected') {
    FB.api('me/likes/' +fb_page_id_or_fb_user_id, function(likes) {
      if (likes.data.length > 0) {
        alert('yaay, page liked');
      }
    });
  } else {
    alert('unable to connect to fb');
  }
}, {scope: 'user_likes'});

將like按鈕放在另一個元素中並添加到其中onclick

<div onclick="doSomething();">
    <fb:like href="[my_url]" layout="button_count" show_faces="false" width="20" font="">  </fb:like>
</div>

只是在這里有一個被接受的ansver。

我不認為這是可能的,我最終放棄了。

我認為Facebook不希望人們知道Like按鈕是否被點擊,因為Facebook不希望任何人強​​迫人們喜歡任何東西。

如果有人得到了更好的答案,請告訴我,但是現在,我認為正確的答案是,不,這是不可能的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM