我有以下代码,它是一个喜欢 facebook 页面的按钮和警报:感谢喜欢,我试图检查页面加载以查看用户是否已经喜欢该页面,并警告“页面已经喜欢”或“页面尚未被点赞”。
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: '637166706299573', status: true, cookie: true, xfbml: true});
FB.Event.subscribe('edge.create', function(href, widget) {
alert('Thanks for the Like');
});
};
(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<script type="text/javascript" src="facebook.js"></script>
<fb:like href="https://www.facebook.com/Tabyeed" layout="button_count" show-faces="true" width="450" action="like" colorscheme="light" font="arial"></fb:like>
我试过了,但没有用:
<script type="text/javascript">
function liked() {
FB.api("me/likes/348028968575501", function(response) {
if (response.data.length == 1) {
alert("page liked already");
} else {
alert("page is NOT liked already");
}
});
}
</script>
有帮助吗?
谢谢