<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '852326038140685',
xfbml : true,
version : 'v2.1'
});
// ADD ADDITIONAL FACEBOOK CODE HERE AS YOU DESIRE
};
(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 = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Place following code after FB.init call.
function onLogin(response) {
if (response.status == 'connected') {
FB.api('/me?fields=first_name', function(data) {
var welcomeBlock = document.getElementById('fb-welcome');
welcomeBlock.innerHTML = 'Hello, ' + data.first_name + '!';
});
}
else {
var welcomeBlock = document.getElementById('fb-welcome');
welcomeBlock.innerHTML = 'Cant get data ' + response.status + '!';}
}
FB.getLoginStatus(function(response) {
// Check login status on load, and if the user is
// already logged in, go directly to the welcome message.
if (response.status == 'connected') {
onLogin(response);
} else {
// Otherwise, show Login dialog first.
FB.login(function(response) { onLogin(response);} , {scope: 'user_friends, email'} );
}
});
</script>
Hello World
<h1 id="fb-welcome"></h1>
Should have inserted name above
</body>
</html>