<!doctype html>
<html>
<head>
<title>WEB Welcome</title>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-3.1.1.js"></script>
<script>
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
// 로그인이 되어있다면 connected 상태가 된다
if (response.status === 'connected') {
// Logged into your app and Facebook.
console.log('logined');
testAPI();
} else {
console.log('not logined');
// The person is not logged into your app or we are unable to tell.
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
}
}
// This function is called when someone finishes with the Login
// Button. See the onlogin handler attached to it in the sample
// code below.
// 로그인이 되었는지 아닌지 상태를 체크한다
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
// 앱 초기화 init
window.fbAsyncInit = function() {
FB.init({
appId : '338796300298727',
xfbml : true,
version : 'v3.2'
});
// FB.AppEvents.logPageView();
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
// sdk를 다운받아서 페이지로 가져옴
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function testAPI() {
console.log('Welcome! Fetching your information.... ');
// 이름을 가져오기 위해 api 사용. /me는 로그인한 유저를 가르킨다
FB.api('/me', function(response) {
//console.log(response);
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
}
</script>
</head>
<body>
<div
class="fb-like"
data-share="true"
data-width="450"
data-show-faces="true">
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/ko_KR/sdk.js#xfbml=1&version=v3.2&appId=2085645551760952&autoLogAppEvents=1';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-login-button" data-max-rows="1" data-size="large" data-button-type="continue_with" data-show-faces="false" data-auto-logout-link="true" data-use-continue-as="false"></div>
</div>
</body>
</html>