Gigya Job Openings

Get Friends Information Demo

Skip to end of metadata
Go to start of metadata

Facebook has deprecated the endpoint that is used by Gigya's socialize.getFriendsInfo API that powers this demo. Be aware that the Facebook endpoint may cease to function at any time, which may break implementations using the socialize.getFriendsInfo API with Facebook data.


See it in Action

Step 1: Connect

Step 2: Get Friends
Click the button below to retrieve your social network friends

Read More

Friends object

API Reference

Check Out the Code

	<SCRIPT type="text/javascript" lang="javascript" 
<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 });
	    function renderUI(res) {
	        // enable/disable "Get Friends" button
	        var connected = (res.user != null && res.user.isConnected);
	        document.getElementById('btnGetFriends').disabled = !connected;
	        // clear friend list if not connected
	        if (!connected)
	            document.getElementById('friends').innerHTML = "";
	    // Get the user's friends
	    function getFriends() {
	        gigya.socialize.getFriendsInfo({ callback: getFriends_callback });
	        document.getElementById('btnGetFriends').disabled = true;
	    // Use the response of getFriends and render HTML to display the first five friends.
	    function getFriends_callback(response) {
	        document.getElementById('btnGetFriends').disabled = false;
	        document.getElementById('friends').innerHTML = "";
	        if (response.errorCode == 0) {
	            var array = response.friends.asArray();
	            var html = "You have " + array.length + " friends, here are a few of them:<BR/>";
	            html += "<table cellpadding=20><tr>";
	            for (var i = 0; i < Math.min(5, array.length); i++) {
	                html += "<td align=center valign='bottom'>";
	                if (array[i].thumbnailURL)
	                    html += "<img width='50' height='50' src='" 
	                    + array[i].thumbnailURL + "' ><br>";
	                html += array[i].nickname + "</td>";
	            html += "</tr></table>";
	            document.getElementById('friends').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
			,containerID: "divConnect" // The component will embed itself inside the divConnect Div 
    <br />
    <h5>Step 2: Get Friends</h5>
    <div style="margin-top:5px;">
    Click the button below to retrieve your social network friends
    </div><br /><br />
    <input id="btnGetFriends" type="button" value="Get Friends" 
            onclick="getFriends()" disabled=true/>
	<br /><br />
    <div id="friends"></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>.