<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<meta property="fb:app_id" content="270946730017302" />
</head>
<body>
<h3>
<div
class="fb-like"
data-share="true"
data-width="450"
data-show-faces="true" data-notify="true">
</div>
<div class="fb-follow" data-href="https://www.facebook.com/sherrydresses" data-layout="standard" data-size="small" data-show-faces="true" data-notify="true"></div>
</h3>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '270946730017302',
xfbml : true,
version : 'v2.9',
status: false,
cookie : true,
oauth: true
});
// In your JavaScript
var auth_response_change_callback = function(response) {
console.log("auth_response_change_callback");
console.log(response);
// alert(response);
}
var auth_status_change_callback = function(response) {
console.log("auth_status_change_callback: " + response);
}
var edge_create = function(response,object) {
console.log("edge_create: " + response+object.className);
}
// FB.Event.subscribe('auth.authResponseChange', auth_response_change_callback);
// FB.Event.subscribe('auth.statusChange', auth_status_change_callback);
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
// alert(uid);
console.log(uid);
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
// alert('the user is logged in to Facebook, ');
console.log('the user is logged in to Facebook, ');
} else {
// the user isn't logged in to Facebook.
// alert('the user isnt logged in to Facebook. ');
console.log('the user isnt logged in to Facebook. ');
}
},true);
FB.Event.subscribe('auth.authResponseChange', auth_response_change_callback);
FB.Event.subscribe('auth.statusChange', auth_status_change_callback);
FB.Event.subscribe('edge.create', edge_create);
FB.Event.subscribe('edge.remove', edge_create);
FB.AppEvents.logPageView();
};
(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";
// js.src = "//connect.facebook.net/en_US/sdk/debug.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
</body>
</html>
https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/v2.9