[英]How to check IF user has ALREADY liked the facebook page
I used the facebook after liked redirection code like this . 我喜欢这样的重定向代码后使用了facebook。 but I cant find a solution for user already liked.
但我找不到已经喜欢的用户的解决方案。 if user already liked redirect page.
如果用户已经喜欢重定向页面。
the code is 该代码是
<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 also liked
{
window.location = "http://www.example.com/FacebookAutoRedirect.asp";
}**
};
//Load the 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 only possible if you authorize the user (you need a Facebook app for that), with the "user_likes" permission > After that you can read his likes and check if he liked a specific page. 仅当您授权用户(为此需要一个Facebook应用)并具有“ user_likes”权限时,这才可能>在此之后,您可以阅读他的喜欢并检查他是否喜欢特定页面。
Facebook docs about user login: https://developers.facebook.com/docs/reference/javascript/FB.login/ 有关用户登录的Facebook文档: https : //developers.facebook.com/docs/reference/javascript/FB.login/
Careful with that, you cannot just open it without any user interaction: 请注意,如果没有任何用户交互,就不能打开它:
Calling FB.login results in the JS SDK attempting to open a popup window.
调用FB.login会导致JS SDK尝试打开一个弹出窗口。 As such, this method should only be called after a user click event, otherwise the popup window will be blocked by most browsers.
因此,仅在用户单击事件之后才调用此方法,否则大多数浏览器将阻止弹出窗口。
Or with the PHP SDK: https://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/ 或使用PHP SDK: https : //developers.facebook.com/docs/reference/php/facebook-getLoginUrl/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.