-
-
Save fake-or-dead/4283554 to your computer and use it in GitHub Desktop.
Fork for accident create this gist in anonymous name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
console.log("facebook loading..."); | |
var j; | |
// check facebook available | |
if($('#fb-root').length === 0) { | |
// not found fb-root prepend element to body | |
$('body').prepend("<div id='fb-root'></div>"); | |
// and load javascript for facebook | |
j = document.createElement('script'); | |
j.type = 'text/javascript'; | |
j.src = '//connect.facebook.net/en_US/all.js'; | |
$('#fb-root').append(j); | |
} | |
$(document).ready(function() { | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId : 'YOUR APP ID', // App ID | |
status : true, // check login status | |
cookie : true, // enable cookies to allow the server to access the session | |
xfbml : true, // parse XFBML | |
frictionlessRequests: true // Allow frictionless request | |
}); | |
window.fbAsyncInitCalled = true; | |
}; | |
}); | |
})(window.jQuery); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="js/facebook.js"></script> | |
<script type="text/javascript" src="js/script.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fbAsyncInitCallback = setInterval(function() { | |
if(window.fbAsyncInitCalled) { | |
console.log('FB already loaded'); | |
// test | |
FB.api('/me', function(resp) { | |
console.log(resp); | |
}) | |
// subscribe to event | |
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; | |
console.log(">> facebook connect >> here is xss fb"); | |
} | |
else if (response.status === 'not_authorized') { | |
// the user is logged in to Facebook, | |
// but has not authenticated your app | |
console.log("the user is logged in to Facebook, but has not authenticated your app"); | |
} | |
else { | |
// the user isn't logged in to Facebook. | |
console.log("the user isn't logged in to Facebook."); | |
} | |
}); | |
// Comment detect | |
FB.Event.subscribe('comment.create', function(response) { | |
console.log(response); | |
}); | |
// Like Detect | |
FB.Event.subscribe('edge.create', function(response) { | |
console.log(response); | |
}); | |
clearInterval(fbAsyncInitCallback); | |
} | |
else { | |
console.log('+'); | |
} | |
}, 2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment