好扎卡里,您對Facebook的連接有點誤解。當用戶點擊放置在您網站上的Facebook連接按鈕時,Facebook不會訪問您的數據庫來驗證用戶身份。他在他的數據庫中驗證用戶是否當前用戶有Facebook帳戶...如果他/她有帳戶,那麼Facebook通過將他登錄到Facebook來爲該特定用戶頒發訪問令牌。那麼現在您有責任在系統中登錄該用戶,並將他的信息放入您的數據庫。讓我進一步解釋並看看下面的代碼
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: "Your APP ID",
status: true,
cookie: true,
xfbml: true});
FB.getLoginStatus(function(response) {
if (response.session) {
// This is the place where you get control when user is login to facebook
// At this point you can redirect the user to a page where you can put the facebook returned information to database and login him into your system
} else {
}
});
FB.Event.subscribe("auth.login", function(response) {
window.location.reload();
});
FB.Event.subscribe("auth.logout", function(response) {
self.location.href="http://www.iranibash.com/logout.php";
});
};
(function() {
var e = document.createElement("script");
e.src = document.location.protocol + "//connect.facebook.net/en_US/all.js";
e.async = true;
document.getElementById("fb-root").appendChild(e);
}());
</script>
現在您可以使用Facebook成功登錄後返回您的用戶信息。您可以在$ cookie中獲得該信息。我認爲你可以從這些信息中瞭解嗎?