javascript - How to check IF user has ALREADY liked the facebook page -
i used facebook after liked redirection code . cant find solution user liked. if user liked redirect page.
the code
<script type="text/javascript"> window.fbasyncinit = function() { fb.init({appid: 'xxxxxxxxxxxxxxxxx', status: true, cookie: true, xfbml: true }); fb.canvas.setsize({ width: 400, height: 80 }); fb.event.subscribe('edge.create', function(response) { alert('thank you'); // put redirect code here eg window.location = "http://www.example.com/facebookautoredirect.asp"; } ); **if liked { window.location = "http://www.example.com/facebookautoredirect.asp"; }** }; //load sdk asynchronously (function() { var e = document.createelement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/tr_tr/all.js'; document.getelementbyid('fb-root').appendchild(e); }()); </script>
best regards
that´s possible if authorize user (you need facebook app that), "user_likes" permission > after can read likes , check if liked specific page.
facebook docs user login: https://developers.facebook.com/docs/reference/javascript/fb.login/
careful that, cannot open without user interaction:
calling fb.login results in js sdk attempting open popup window. such, method should called after user click event, otherwise popup window blocked browsers.
or php sdk: https://developers.facebook.com/docs/reference/php/facebook-getloginurl/
Comments
Post a Comment