|
@@ -31,21 +31,17 @@
|
|
|
<body id="top">
|
|
|
<script>
|
|
|
function statusChangeCallback(response) { // Called with the results from FB.getLoginStatus().
|
|
|
- console.log('statusChangeCallback');
|
|
|
- console.log(response); // The current login status of the person.
|
|
|
- if (response.status === 'connected') { // Logged into your webpage and Facebook.
|
|
|
+ if (response.status === 'connected') { // 已登入
|
|
|
testAPI();
|
|
|
- } else { // Not logged into your webpage or we are unable to tell.
|
|
|
- // document.getElementById('status').innerHTML = 'Please log ' +
|
|
|
- // 'into this webpage.';
|
|
|
+ } else { // 未登入
|
|
|
$('#status').html('FB登入按扭(開發中),請勿點擊');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function checkLoginState() { // Called when a person is finished with the Login Button.
|
|
|
+function checkLoginState() { // Called when a person is finished with the Login Button.
|
|
|
FB.getLoginStatus(function(response) { // See the onlogin handler
|
|
|
statusChangeCallback(response);
|
|
|
- });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
window.fbAsyncInit = function() {
|
|
@@ -53,15 +49,15 @@ window.fbAsyncInit = function() {
|
|
|
appId : '1388696554848391',
|
|
|
cookie : true, // Enable cookies to allow the server to access the session.
|
|
|
xfbml : true, // Parse social plugins on this webpage.
|
|
|
- version : 'v11.0' // Use this Graph API version for this call.
|
|
|
+ version : 'v11.0' // Use this Graph API version for this call.
|
|
|
});
|
|
|
|
|
|
FB.getLoginStatus(function(response) { // Called after the JS SDK has been initialized.
|
|
|
- statusChangeCallback(response); // Returns the login status.
|
|
|
+ statusChangeCallback(response); // Returns the login status.
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-function testAPI() { // Testing Graph API after login. See statusChangeCallback() for when this call is made.
|
|
|
+function testAPI() {
|
|
|
FB.api('/me/?fields=id,name,email', function(response) {
|
|
|
console.log('FB API回傳資料: ' + JSON.stringify(response));
|
|
|
|
|
@@ -70,8 +66,6 @@ function testAPI() { // Testing Graph API after login. See
|
|
|
document.getElementById("email").value = response.email;
|
|
|
document.getElementById("name").value = response.name;
|
|
|
|
|
|
- console.log('隱藏FB登入按鈕');
|
|
|
-
|
|
|
// 隱藏FB登入按鈕
|
|
|
document.getElementById("fb_login").style.display = 'none';
|
|
|
}
|