facebook php example....
https://developers.facebook.com/docs/reference/php
FB.login(function (response) {
if (response.authResponse) {
FB.api('/me', function (response) {
//所以 login 後可以直接取得下面的值,並傳入 CheckPlayer 這 function
//然後在 CheckPlayer 中透過AJAX在資料庫中檢查並寫入資料庫
CheckPlayer(response.id, response.name, response.email,response.birthday);
});
} else {
alert('登入失敗!');
}
}, {
scope: 'email,user_birthday'
});
}
});
function CheckPlayer(uid, cname, email, birthday) {
$.ajax({
url: 'AJAX/CheckGamePlayer.aspx',
type: 'POST',
data: { uid: uid, cname: cname, email: email, birthday: birthday },
dateType: 'html',
success: function () {
//檢查資料庫並新增完之後就看要幹嘛
}
})
}
Reference : http://sweeteason.pixnet.net/blog/post/37284400-%E7%B6%B2%E7%AB%99%E5%88%A9%E7%94%A8-facebook-%E5%B8%B3%E8%99%9F%E7%99%BB%E5%85%A5-(javascript-sdk)
沒有留言:
張貼留言