Last active
December 12, 2015 12:09
-
-
Save dommmel/4770411 to your computer and use it in GitHub Desktop.
This file contains 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
<!DOCTYPE html> | |
<html><head></head> | |
<!-- Standard Facebook Initialization --> | |
<body> | |
<div id="fb-root"></div> | |
<button>Loading...</button> | |
<script> | |
/*************************************** | |
* | |
* Fill in your API-Key here | |
* | |
***************************************/ | |
var _ppq = _ppq || []; // make sure _ppq is initialized before the facebook sdk is loaded | |
_ppq.push(['setApiKey', PEERPOINTER_API_KEY]); | |
/*************************************** | |
* | |
* load peerpointer SDK asynchronous | |
* | |
***************************************/ | |
(function(d){ | |
var pp = document.createElement('script'), id = 'peerpointer-jsdk', ref = d.getElementsByTagName('script')[0]; | |
pp.type = 'text/javascript'; pp.async = true; | |
if (d.getElementById(id)) {return;} | |
pp.src = "//api.peerpointer.com/pp.js"; | |
//pp.src = "//api.peerpointer.com"; | |
ref.parentNode.insertBefore(pp, ref); | |
}(document)); | |
/*************************************** | |
* | |
* Standard facebook initialization | |
* | |
***************************************/ | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId : FACEBOOK_APP_ID, | |
status : true, | |
cookie : true, | |
xfbml : true | |
}); | |
FB.getLoginStatus(function(response) { | |
if (response.status === 'connected') { | |
makeLogoutButton(); | |
} else if (response.status === 'not_authorized') { | |
makeLoginButton(); | |
} else { | |
makeLoginButton(); | |
} | |
} | |
); | |
}; | |
window.button = document.getElementsByTagName("button")[0] | |
function makeLoginButton() { | |
button.onclick=login; | |
button.innerHTML="Log in via facebook" | |
} | |
function makeLogoutButton() { | |
button.onclick=function(){FB.logout(function(re){makeLoginButton()})}; | |
button.innerHTML="Log out" | |
} | |
function login() { | |
FB.login(function(response) { | |
if (response.authResponse) { // connected | |
makeLogoutButton(); | |
/************************************************ | |
* | |
* This is where the call to peerpointer happens | |
* | |
************************************************/ | |
_ppq.push(["createAndCrawl", response.authResponse.accessToken]); | |
} else { | |
// cancelled | |
} | |
/************************************************* | |
* | |
* Be shure to check all the relevant permissions | |
* | |
*************************************************/ | |
},{scope: 'user_likes,read_stream,friends_likes'}); | |
} | |
(function(d){ | |
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; | |
if (d.getElementById(id)) {return;} | |
js = d.createElement('script'); js.id = id; js.async = true; | |
js.src = "//connect.facebook.net/en_US/all.js"; | |
ref.parentNode.insertBefore(js, ref); | |
}(document)); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment