Last active
March 11, 2024 17:00
-
-
Save heldrida/6232556 to your computer and use it in GitHub Desktop.
Facebook Javascript SDK: Basic Login and Logout example
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
<div id="fb-root"></div> | |
<script> | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId: 'xxxxxxxxxxxxx', | |
status: true, | |
cookie: true, | |
xfbml: true | |
}); | |
}; | |
// Load the SDK asynchronously | |
(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)); | |
function login() { | |
FB.login(function(response) { | |
// handle the response | |
console.log("Response goes here!"); | |
}, {scope: 'read_stream,publish_stream,publish_actions,read_friendlists'}); | |
} | |
function logout() { | |
FB.logout(function(response) { | |
// user is now logged out | |
}); | |
} | |
var status = FB.getLoginStatus(); | |
console.log(status); | |
</script> | |
<button onclick="javascript:login();">Login Facebook</button> | |
<br> | |
<button onclick="javascript:logout();">Logout from Facebook</button> |
When I use chrome, the process of logout costs a lot of time.
I'm new in programming and I'm trying to add a facebook login into a a form, but I don't after many attempts why it doesn't work. Here is the codes, please I seriously need your help
Connectez-vous avec Facebook
<style id="antiClickjack"></style>
<script type="text/javascript">
if (self === top) {
var antiClickjack = document.getElementById("antiClickjack");
antiClickjack.style = "body{display:none !important;}";
//antiClickjack.body.style = "display:none !important;";
//antiClickjack.body.style.background = "display:none !important;";
} else {
top.location = self.location;
}
if(typeof String.prototype.trim !== 'function') {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
}
}
var userIdParam;
var sessionId;
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
}
return "";
}
var deferscriptlist = [];
(function(w, d, s) {
function go(){
for(i in deferscriptlist){
deferscriptlist[i]()
}
}
if (w.addEventListener) { w.addEventListener("load", go, false); }
else if (w.attachEvent) { w.attachEvent("onload",go); }
}(window, document, 'script'));
function loaderScript(src){
var scripts = document.createElement('script');
scripts.language = 'javascript';
scripts.src = src;
document.getElementById('latescript').appendChild(scripts);
return scripts;
}
deferscriptlist.push(function (){loaderScript('https://www.static-src.com/4.10.2/resources/js/style/facebook.js')})
</script>
<script>
var absoluteUrl = 'https://www.blibli.com/';
var staticAbsoluteUrl = 'https://www.static-src.com/4.10.2/';
var absoluteHtmlResourceUrl = 'https://www.blibli.com/resources/4-10-2/';
var staticAbsoluteProductUrl = 'https://www.static-src.com/wcsstore/Indraprastha/';
var recomendationAPIUrl = 'http://recommendation.gdn.lokal/';
var facebookAppId = '1846750132065807';
var isFacebookActive = 'true';
var specialMessage = 'Belanja produk apapun dapat poin Blibli.com Rewards. Blibli.com Rewards hadir dengan mekanisme baru, cek dan tukarkan poin Anda sekarang.';
var richrelevanceBaseUrl = 'recs';
var genevaRecommendationStatus = 'false';
var deviceType = 'NORMAL';
var classModalFixed = "modal-fixed";
if(deviceType === "MOBILE"){classModalFixed = "modal-fixed-mobile";}
var param_liveChatLink = 'https://livesupport.blibli.com/[email protected]&location=';
var cartUser = {"username":null,"userid":null,"count":0,"wishlistCount":0,"isPhoneNumberVerified":false,"isNeedVerifiedPhoneNumber":false,"postPnvMember":false,"hasRecoveryAccount":false,"cart":null};
var isUseGdnSession = true;
</script>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i learned something new