Social Connect Javascript API Complete Code
(Difference between revisions)
Renato.neves (Talk | contribs) |
Renato.neves (Talk | contribs) |
||
Line 62: | Line 62: | ||
socialid.events.onConnectStart.addHandler(function(data) { | socialid.events.onConnectStart.addHandler(function(data) { | ||
console.log("Website received onConnectStart: ", data); | console.log("Website received onConnectStart: ", data); | ||
+ | }); | ||
+ | socialid.events.onDisconnectSuccess.addHandler(function(data) { | ||
+ | console.log("Website received onDisconnectSuccess: ", data); | ||
+ | }); | ||
+ | socialid.events.onDisconnectError.addHandler(function(data) { | ||
+ | console.log("Website received onDisconnectError: ", data); | ||
}); | }); | ||
} | } |
Revision as of 20:30, 19 July 2013
<script> //<![CDATA[
// load the Social-ID Javascript API (function(){ if (typeof(window.socialid) !== "object") window.socialid = {}; socialid.onLoad = function() { showConnectWidget(); customConnectButtons(); eventHandlers(); }; var e = document.createElement('script'); e.type = 'text/javascript'; e.id = 'socialid_api_script'; if (document.location.protocol === 'https:') { e.src = 'https://app.socialidnow.com/assets/api/socialid.js'; } else { e.src = 'http://app.socialidnow.com/assets/api/socialid.js'; } var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(e, s); })();
// render the connect widget function showConnectWidget() { socialid.login.init(36, {loginType: "event"}); socialid.login.renderConnectWidget("socialid_connect_container", { theme: "bricks", providers: ["facebook", "twitter", "linkedin"], language: "pt_br", showSocialIdLink: true, loadCss: true }); }
// start connect for custom buttons function customConnectButtons() { // start connect process when user clicks on facebook button facebook_button = document.getElementById("facebook_connect"); facebook_button.onclick = function() { socialid.login.startConnect("facebook"); }; // start connect process when user clicks on twitter and linkedin button socialid.login.startConnectClick("twitter_connect", "twitter"); socialid.login.startConnectClick("linkedin_connect", "linkedin"); }
// add event handlers function eventHandlers() { socialid.events.onConnectSuccess.addHandler(function(data) { console.log("Website received onConnectSuccess: ", data); }); socialid.events.onLoginSuccess.addHandler(function(data) { console.log("Website received onLoginSuccess: ", data); }); socialid.events.onConnectCancel.addHandler(function(data) { console.log("Website received onConnectCancel: ", data); }); socialid.events.onConnectError.addHandler(function(data) { console.log("Website received onConnectError: ", data); }); socialid.events.onConnectStart.addHandler(function(data) { console.log("Website received onConnectStart: ", data); }); socialid.events.onDisconnectSuccess.addHandler(function(data) { console.log("Website received onDisconnectSuccess: ", data); }); socialid.events.onDisconnectError.addHandler(function(data) { console.log("Website received onDisconnectError: ", data); }); }
//]]> </script>