Returns information about friends of the current user. This method supports getting either basic or extended information for all or some of the user's friends.

Description

 

Returns information about friends of the current user. This method supports getting either basic or extended information for all or some of the user's friends. The method returns the user's friends from all the connected providers that support friends feature.
Note that retrieving friends' data should be requested explicitly by checking the appropriate checkbox in the console's permissions section. 

In some cases, you can use the getRawData API to retrieve data directly from the provider for information that is not natively provided by Gigya.

 

Important Notes:
Retrieving the list of friends from the different providers may be a lengthy operation, depending on the number of friends and the performance of each provider. Gigya begins retrieving the list to its cache immediately after the user logs in but if you call this method too soon after the login, the friends list may not be available yet. In this case the server will return statusCode 100 and errorCode 100001 which means: "Data pending". You may wait a while and retry the call or modify your application flow to not require this information immediately after the user logs in.
Please note, that since retreiving friends list is a lengthy operation, Gigya caches the friends list for 24 hours or until a successful login.

 

REST API > socialize.getFriendsInfo.

Supporting Providers

The following providers currently support this operation: , FourSquare, Renren, Vkontakte, mixi, Yahoo JapanXing.

Note: Our definition of a 'friend' in Twitter, is a person who is both a 'follower' and is in the 'following' list of the current user.

Securing the getFriendsInfo Process

The Gigya service supports a mechanism to verify the authenticity of the getFriendsInfo process.
If the
global configuration object's signIDs field is set to 'true', Gigya "signs" each friend with a cryptographic signature to prevent fraud.
As part of the response object, your site will receive the list of friends in the getFriendsInfo's callback function (please refer to the Response object Data Members table below). Each Friend object has a cryptographic signature (friendshipSignature data member) provided by Gigya.
We highly recommend verifying the authenticity of the signature to prove that it has indeed originated from Gigya rather than somewhere else.
To learn more about this subject, please refer to the Validate Friendship Signatures section in the Security page of the Developer's Guide.

 

 

RequiredNameTypeDescription
detailLevelstringThis field indicates whether to get basic or extended information about each friend. See the Friend object page for details on which fields are included for each detail level.

Allowed values are:
basic - Basic detail level. This is the default.
extended - Extended detail level.

friendsCollectionA collection of Friend objects representing a list of friends (as returned by the Friends Selector Plugin). When this parameter is provided, the function returns information only about the friends in the list.
This is useful if you want to get information about friends who were selected using the Friend Selector plugin.
UIDsstringDeprecated.
siteUsersOnlyBooleanIf the parameter is set to 'true' then only the friends who are also site users are returned. The default value of this parameter is 'false'.
callbackfunction
enabledProvidersstring , foursquare', 'renren'', 'vkontakte', 'mixi', 'yahoojapan', 'xing'.
disabledProvidersstring foursquare', 'renren', 'vkontakte', 'mixi', 'yahoojapan', 'xing'.
requiredCapabilitiesstringDeprecated.
cidstring
contextobject

 

FieldTypeDescription
friendsCollectionA collection of Friend objects, corresponding to the list of friends of the current user on all the social networks to which the user is connected.
If either the 'friends' or 'UIDs' input parameters are provided in the function call, only the specified friends are retrieved.
UIDsstringA comma-separated list of UIDs of friends of the current user.
Note: The UIDs list is equivalent to the 'friends' collection field.

 

Code Sample

function printResponse(response) {   
    if ( response.errorCode == 0 ) {
        //convert the 'friends' collection into an array             
        var myFriends = response['friends'].asArray();  
        // Do some stuff with the info.         
        if ( null!=myFriends && myFriends.length>0) {        
            var msg = response['context']['myFriendsTitle'] + '\n\n';        
            for (var index in myFriends) {
                var currFriend = myFriends[index];
                msg += currFriend['name'] + '('+currFriend['nickname']+') - '+ currFriend['photoURL']+ ':\n' ;                 
            }            
            alert(msg);
        }
        else {
            alert('No friends were returned');
        }
    }
    else {
        alert('Error :' + response.errorMessage);
    }
}

var context = {
        myFriendsTitle : 'My friends are:'
};

var params = {
    //detailLevel = 'extended' is required to receive extended information such as birthdate, country etc'.
    detailLevel:'extended',
    context:context, 
    //User who's friends info we want to retrieve
    UIDs:'_gid_3VgBvTtCGqDTEtcZMGL08w==,_gid_1FyT4hKPcD+oCM121MM+Q==',
    callback:printResponse
};

gigya.socialize.getFriendsInfo(params);

 

In the Get Friends Information page you will find a complete working example that uses the socialize.getFriendsInfo method. You may view the code, run it and view the outcome.

 

<script>
$(document).ready(function() {
    lssdk.tableFixer();
	lssdk.tables.removeText(tVar0, 'googleplus,');
});
</script>