|
|
|
|
Page last modified 13:53, 17 Mar 2010 by shirly
Gigya's Developer Documentation > API Reference > Client API (JavaScript & AS3) > Methods > socialize.getFriendsInfo
socialize.getFriendsInfoFrom $1Table of contents
DescriptionReturns 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 will return the user's friends from all the connected providers which support friends feature. Note: This method is also supported in our REST API. If you wish to execute this method from your server, please refer to REST API > socialize.getFriendsInfo. Supporting ProvidersThis operation currently supported by the following providers: Facebook, Myspace, Twitter, Yahoo, LinkedIn. 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 ProcessGigya Socialize supports a mechanism to verify the authenticity of the getFriendsInfo process. If the Conf object's "signIDs" field is set to "true", Gigya "signs" each friend with a cryptographic signature, to prevent fraud. Your site will receive in getFriendsInfo's callback function the list of friends as part of the response object (please refer to the Response object Data Members table below). Each Friend object has a cryptographic signature (friendshipSig data member) provided by Gigya. We highly recommend verifying the authenticity of the signature to prove that it is indeed originating from Gigya, rather than somewhere else. To learn more about this subject, please refer to the Cryptographic Signatures section in the Security page of the Developer's Guide.
Syntax
Method parametersconf objectPlease refer to the Conf object page for full specifications. params object members
Response object Data Members
Code Samplevar conf = {
APIKey:'2_fA4cZD0cEmxKUjDdNai8hyK4fZ-Jq7w4qm1x-pkS-7E6NDm90gAmrdcugVoaewUS'
};
function printResponse(response) {
if ( response.errorCode == 0 ) {
var myFriends = response['friends'].asArray();
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',
context:context,
UIDs:'_gid_3VgBvTtCGqDTEtcZMGL08w==,_gid_1FyT4hKPcD+oCM121MM+Q==',
callback:printResponse
};
gigya.services.socialize.getFriendsInfo(conf,params);
function printResponse(response:Object):void {
if ( response.errorCode == 0) {
var myFriends:Array = response['friends'].asArray();
if ( null!=myFriends && myFriends.length>0) {
var msg:String = response['context']['myFriendsTitle'] + '\n\n';
for (var index:String in myFriends) {
var currFriend:Object = myFriends[index];
msg += currFriend['name'] + '('+currFriend['nickname']+') - '+ currFriend['photoURL']+ ':\n' ;
}
trace(msg);
}
else {
trace('No friends were returned');
}
}
else {
trace('Error :' + response.errorMessage);
}
}
function getFriendsInfo():void {
var conf:Object = { // Note: best practice is, to define one global conf object and use it throughout the application
mcRoot:this.root,
APIKey:'2_fA4cZD0cEmxKUjDdNai8hyK4fZ-Jq7w4qm1x-pkS-7E6NDm90gAmrdcugVoaewUS'
};
var context:Object = {
myFriendsTitle : 'My friends are:'
};
var params:Object = {
detailLevel:'extended',
context:context,
UIDs:'_gid_3VgBvTtCGqDTEtcZMGL08w==,_gid_1FyT4hKPcD+oCM121MM+Q==',
callback:printResponse
};
gigya.services.socialize.getFriendsInfo(conf,params);
}
Notes:
In "Get Friends Information" page you will find a complete working example which uses socialize.getFriendsInfo method. You may view the code, run it and view the outcome. Retrieved from "http://wiki.gigya.com/030_API_reference/010_Client_API/020_Methods/socialize.getFriends"
Tags:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Viewing Details: