javascript - Check if User liked Facebook page or not -
i have following code, button facebook page, , alerts: like, trying check on page load see if user has liked page or not, , alert "page liked" or "page not liked yet".
<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 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>
i tried didn't work :
<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 not liked already"); } }); } </script>
any guys?
thanks
i don't see login button/flow best guess fb.api("me/likes/348028968575501"
fail because user isn't authenticated different event subscribe doesn't rely on authentication.
Comments
Post a Comment