You are not logged in.   Log in | Register

socialize.getUserInfo

From $1

Description

This method is used to retrieve extended information regarding the current user. The information returned by this method is represented by a "User object". See the "User object" page for the full specification of the information available.

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.getUserInfo.

Syntax

gigya.services.socialize.getUserInfo(conf,params)

 

Method parameters

conf object

Please refer to the Conf object page for full specifications.

params object members

Required Name Type Description
Optional callback function A reference to a callback function. Gigya will call the specified function along with the results of the API method when the API method completes.
The callback function should be defined with the following signature: functionName(response)
The "Response object Data Members" table below provides specification of the data which is passed to the callback function.
  cid string A string of maximum 100 characters length. This string will be associated with each transaction and will later appear on reports generated by Gigya, in the "Context ID" combo box. The cid allows you to associate the report information with your own internal data, for example, to identify a specific widget or page on your site/application. The "Context ID" combo box lets you filter the report data by site/application context.
Note: the value of this parameter overrides the value of the identical parameter in the Conf object.
  context object A developer-created object that will be passed back unchanged to the application as one of the fields in the response object.

 

Response object Data Members

Field Type Description
errorCode integer The result code of the operation. Code '0' indicates success, any other number indicates failure. For a complete list of error codes, see the Error Codes table.
errorMessage string A short textual description of an error, associated with the errorCode, for logging purposes.
operation string The name of the API method that generated this response.
context object The context object passed by the application as parameter to the API method, or null if no context object has been passed.
user User object User object with updated information for the current user.

 

Code Sample

var conf = { 
    APIKey:'2_fA4cZD0cEmxKUjDdNai8hyK4fZ-Jq7w4qm1x-pkS-7E6NDm90gAmrdcugVoaewUS'
};

function printResponse(response) {  
    if ( response.errorCode == 0 ) {             
        var user = response['user'];
        var msg = 'User '+user['nickname'] + ' is ' +user['age'] + ' years old';
        alert(msg);
    }
    else {
        alert('Error :' + response.errorMessage);
    }  
}

gigya.services.socialize.getUserInfo(conf,{callback:printResponse});
function printResponse(response:Object):void {  
    if ( response.errorCode == 0) {             
        var user:Object = response['user'];
        var msg:String = 'User '+user['nickname'] + ' is ' +user['age'] + ' years old';
        trace(msg);
    }
    else {
        trace('Error :' + response.errorMessage);
    }  
}

function getUserInfo():void {
	var conf:Object = { 
		mcRoot:this.root,
		APIKey:'2_fA4cZD0cEmxKUjDdNai8hyK4fZ-Jq7w4qm1x-pkS-7E6NDm90gAmrdcugVoaewUS'
	};

	gigya.services.socialize.getUserInfo(conf,{callback:printResponse});
}

Notes:
  • This sample is not meant to be fully functional code. For brevity's sake, only the code required for demonstrating the API call itself is presented.
  • The API key in the sample will only work on http://localhost/...
  • To run the code on your own domain, modify the API key in the example to your own API key. A Gigya API Key can be obtained on the Site Setup page on Gigya's website. Please make sure that the domain you are loading the page from is the same domain name that you used for generating the API Key.
  • In some cases it is necessary to connect the user to a provider? prior to calling the API method. For connecting the user to a provider, you may use the Connect API method call or the pre-built Connect Widget.
  • Best practice is, to define one global conf object and use it throughout the application.

 

In "Get User Information" page you will find a complete working example which uses socialize.getUserInfo method. You may view the code, run it and view the outcome.

Tags:
Files (0)