gpt4 book ai didi

javascript - 知道是否点击了 facebook 的按钮

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:27:49 25 4
gpt4 key购买 nike

我需要知道我页面的访问者是否单击了“喜欢”按钮。使用此代码:

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

但是如果用户已经喜欢了我的网站,我怎么知道呢?我不希望他再次不喜欢和喜欢,来举办那个事件。

最佳答案

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/

不能从它所在的页面再次点击它

关于javascript - 知道是否点击了 facebook 的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6408787/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com