Gigya Job Openings

Page History

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This guide explains how to leverage Gigya's plugins to acquire new site users, and log in returning site users. We will guide you on how to integrate these plugins with Social Login and Registration-as-a-Service Customer Identity.

Gigya's sharing and social interaction plugins embed an inner 'Add Connection' plugin:

...

Panel
borderColor#81C0FC
bgColor#F4F7FC
borderWidth1
borderStylesolid

Note: if you are using Gigya's Registration-as-a-ServiceCustomer Identity (Raas) package, the implementation is slightly different and simpler:
    a. You can skip Step 1 mentioned below (this is the default behaviour in the RaaS environment). 
    b. Instead of  socialize.addEventHandlers  API method, use the  accounts.addEventHandlers API method. The usage is the same, but the onLogin event data is different.

...

Code Block
languagexml
linenumberstrue
<html>
<head>
	<SCRIPT type="text/javascript" lang="javascript" 
	   src="http://cdn.gigya.com/JSjs/gigya.js?apikey=<YOUR-API-KEY>">
	</SCRIPT>
	<script>

        // This method is activated when page is loaded
        function onLoad() {

            // register for login event
            gigya.socialize.addEventHandlers({
					onLogin: onLoginHandler 
					,onLogout: onLogoutHandler
					});
        }

        // onLogin Event handler
        function onLoginHandler(eventObj) {	

		   // in this example, we postpone the SignOn flow only in-case of the Share Plugin
		   // in all other cases we do the SignOn flow right away
		   if (eventObj.context != "SharePlugin")
		   {
		       doSignOnFlow(eventObj.user)
		   }
		}
		function doSignOnFlow(userObject) {	
		    alert("logged in");
			document.getElementById('status').style.color = "green";
			document.getElementById('status').innerHTML = "Status: You are now signed in";
        }
        function showShareUI() {

			// Constructing a UserAction Object
			var act = new gigya.socialize.UserAction();
		    act.setUserMessage("Your comment here...");
			act.setTitle("This is my title");
			// ...
			var shareParams = 
			{
			    userAction:act
			    ,context: "SharePlugin" // string to identify the Share Plugin
			    ,onSendDone: onSendDoneHandler // register to the onSendDone event of the Share Plugin
				,cid:''
			};

			// Show the Share Plugin
			gigya.socialize.showShareUI(shareParams);
		}

		// onSendDone Event handler  
		function onSendDoneHandler(eventObj) {

		    // call getUserInfo
		    gigya.socialize.getUserInfo({
		       callback: userInfoCallback,
		       signIDs: true  // sign the user object in the response
		    }); 
		}
		function userInfoCallback(response) {    
			doSignOnFlow(response.user);  
		} 

        // Logout from Gigya platform. This method is activated when "Logout" button is clicked 
		function logoutFromGS() {
            gigya.socialize.logout(); // logout from Gigya platform
        }

		// onLogout Event handler
        function onLogoutHandler(eventObj) {
		    alert("logged out");
			document.getElementById('status').style.color = "red";
			document.getElementById('status').innerHTML = "Status: You are now signed out";
		}
    </script>
</head>
<body onload="onLoad()">
	<h3>Sign in using Plugins Demo</h3>
    <br />
	<h4>Please click the button below to open the "Share" dialog:</h4>
    <input type=button id="btnShare" onclick="javascript:showShareUI()" value="Share" />
	<br /><br /><br />
    <br /><br /><br />
	<h4>Click the button below to sign out from Gigya platform:</h4>
	<br />
    <input id="btnLogout" type="button" value="Sign Out" 
            onclick="logoutFromGS()"/>
    <br />
    <br />
    <div id="status"></div>
</body>
</html>

...