Get User Information Demo

Skip to end of metadata
Go to start of metadata

 

See it in Action

Step 1: Connect

Step 2: See User Info

 

Read More

User Object

API Reference

Check Out the Code

<html>
<head>
    <title></title>
	<SCRIPT type="text/javascript" lang="javascript" 
        src="http://cdn.gigya.com/JS/gigya.js?apikey=3_mK2cmEzLkzhqe4MUrtPncxbv4wKsYAhsew0iVwhVUls3c_Jx_HLX434jAVpq5M_W">
    </SCRIPT>
</head>
<body>
<div id="runningCodeExample" style="border: 1px solid skyblue; padding: 15px; width: 400px; display: block; height: auto;">
	<script>
	    function onLoad() {
	        // get user info
	        gigya.socialize.getUserInfo({ callback: renderUI });
	        // register for connect status changes
	        gigya.socialize.addEventHandlers({ onConnectionAdded: renderUI, onConnectionRemoved: renderUI });
	    }
        function renderUI(res) {
            if (res.user != null && res.user.isConnected) {
                document.getElementById("name").innerHTML = res.user.nickname;
                if (res.user.thumbnailURL.length > 0)
                    document.getElementById("photo").src = res.user.thumbnailURL;
                else
                    document.getElementById("photo").src
                                = "http://cdn.gigya.com/site/images/bsAPI/Placeholder.gif";
                document.getElementById("profile").style.display = "block";
            } else {
                document.getElementById("profile").style.display = "none";
            }
        }
		onLoad();
	</script>	
	
	<h5>Step 1: Connect</h5>
        <div id="divConnect"></div>
    <script type="text/javascript">
        // show 'Add Connections' Plugin in "divConnect"
        gigya.socialize.showAddConnectionsUI({ 
			height:65
			,width:175
			,showTermsLink:false // remove 'Terms' link
			,containerID: "divConnect" // The component will embed itself inside the divConnect Div 
		});
    </script>    
    <br />
    <h5>Step 2: See User Info</h5><br />
    <div id=profile style="display:none;">
        <img id="photo" src="" width="60" />            
        <br />
        <span id="name" ></span>
    </div>
</div>	
</body>
</html>

Notes:

In order to make the above code work in your environment, please note:

  • The API key in the sample will only work on http://localhost/...
  • To load the page from your domain, modify the value of the "APIKey" field in the code to your own Gigya API Key. A Gigya API Key can be obtained from the Site Dashboard page on Gigya's website. Please make sure that the domain from which you are loading the page is the same domain name that you used for generating the API Key.
  • If you are using https, be sure to further adjust the js API url to: https://cdns.gigya.com/JS/gigya.js?apikey=<Your_API_Key>.