window.fbAsyncInit = function() { FB.init({ appId : '2710367452546416', cookie : false, xfbml : true, version : 'v8.0' }); }; let fb = { fbId: undefined, email: undefined, accessToken: undefined, fbLogin: function (fn) { FB.login(function(response) { if (response.status === 'connected') { fb.accessToken = response.authResponse.accessToken; FB.api('/me', {fields: 'id, email'}, function(res) { fb.fbId = res.id; fb.email = res.email; fn(); }); } //else { // alert("Facebook帳號無法登入!"); //} }, {scope: 'public_profile, email'}); } }