[英]How to check IF user has ALREADY liked the facebook page
我喜歡這樣的重定向代碼后使用了facebook。 但我找不到已經喜歡的用戶的解決方案。 如果用戶已經喜歡重定向頁面。
該代碼是
<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>
最好的祝福
僅當您授權用戶(為此需要一個Facebook應用)並具有“ user_likes”權限時,這才可能>在此之后,您可以閱讀他的喜歡並檢查他是否喜歡特定頁面。
有關用戶登錄的Facebook文檔: https : //developers.facebook.com/docs/reference/javascript/FB.login/
請注意,如果沒有任何用戶交互,就不能打開它:
調用FB.login會導致JS SDK嘗試打開一個彈出窗口。 因此,僅在用戶單擊事件之后才調用此方法,否則大多數瀏覽器將阻止彈出窗口。
或使用PHP SDK: https : //developers.facebook.com/docs/reference/php/facebook-getLoginUrl/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.