Gigya Job Openings

Get Email Contacts Demo

Skip to end of metadata
Go to start of metadata


See it in Action

Step 1: Connect

Step 2: Get Contacts
Click the button below to retrieve your email contacts.

Read More

Contact object
API Reference

Check Out the Code


	<script type="text/javascript" lang="javascript" src=""> </script>
	<div id="runningCodeExample" style="border: 1px solid skyblue; padding: 15px; width: 400px; display: block; height: auto;">
	    function onLoad() {
	        // get user info
	        gigya.socialize.getUserInfo({ callback: renderUI });
	        // register for connect status changes
	        gigya.socialize.addEventHandlers({ onConnectionAdded: renderUI, onConnectionRemoved: renderUI });
<script type="text/javascript">
	    function renderUI(res) {
	        // enable/disable "Get Contacts" button
	        var connected = (res.user != null && res.user.isConnected);
	        document.getElementById('btnGetContacts').disabled = !connected;
	        // clear contact list if not connected
	        if (!connected)
	            document.getElementById('contacts').innerHTML = "";
	    // Get the user's contacts ++++++++++++++++++++
	    function getContacts() {
	        gigya.socialize.getContacts({ callback: getContacts_callback });
	        document.getElementById('btnGetContacts').disabled = true;
	    // Use the response of getContacts and render HTML to display the first five contacts.
	    function getContacts_callback(response) {
	        document.getElementById('btnGetContacts').disabled = false;
	        document.getElementById('contacts').innerHTML = "";
	        if (response.errorCode == 0) {
	            var array = response.contacts.asArray();
	            var html = "<br /><br />You have " + array.length + " contacts, here are some of them:<br /><BR/>";
	            html += "<table cellpadding=20>";
	            for (var i = 0; i < Math.min(10, array.length); i++) {
	                html += "<tr><td align=center valign='bottom'>";
	                if (array[i].photoURL)
	                    html += "<img width='50' height='50' src='"
	                    + array[i].photoURL + "' ><br>";
	                html += array[i].firstName + " " + array[i].lastName + ": <br>";
	                html += array[i].email + "</td></tr>";
	            html += "</table>";
	            document.getElementById('contacts').innerHTML = html;
				document.getElementById('runningCodeExample').style.width = '90%';
	        } else {
		        alert('Error :' + response.errorMessage);
<h5>Step 1: Connect</h5>
	    <div id="divConnect"></div>
    <script type="text/javascript">
        // show 'Add Connections' Plugin in "divConnect"
			,showTermsLink:false // remove 'Terms' link
			,requiredCapabilities: "Contacts" // we want to show only providers that support retrieving contacts.
			,containerID: "divConnect" // The component will embed itself inside the divConnect Div 
    <br />
    <h5>Step 2: Get Contacts</h5>
    <div style="margin-top:5px;">
    Click the button below to retrieve your email contacts.
	<br /><br />
    <input id="btnGetContacts" type="button" value="Get Contacts" 
            onclick="getContacts()" disabled=true/>
    <div id="contacts"></div>


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:<Your_API_Key>.