我想知道如何判断一个人是否喜欢我的博客上的帖子,他们是第一个喜欢它的人。
我尝试了这个,但它似乎不起作用。
任何帮助/想法?
<script type='text/javascript'>
function FB.Event.subscribe('edge.create', function(response) {
// user clicked like
alert('Thank you for liking this post');
var query = FB.Data.query('SELECT like_count FROM link_stat WHERE url="' + window.location + '"');
query.wait(function(rows) {
if ( ! rows[0].like_count ) {
alert('Congrats - You are the first person to like this');
}
});
});
</script>
答案 0 :(得分:1)
function
前面有FB.Event.subscribe()
。假设您在此之前调用FB.init()
,并且您的Like按钮网址与window.location
相同,则以下情况应该有效。
<script type='text/javascript'>
FB.Event.subscribe('edge.create', function(response) {
// user clicked like
alert('Thank you for liking this post');
var query = FB.Data.query('SELECT like_count FROM link_stat WHERE url="' + window.location + '"');
query.wait(function(rows) {
if (rows[0].like_count == 1) {
alert('Congrats - You are the first person to like this');
}
});
});
</script>