Last modified 11:46, 15 Sep 2014

The Flash client library provides a ActionScript3 interface for the Gigya API. The library makes it simple to integrate Gigya's service in your Flash application. This document is a practical step-by-step guide for programmers who wish to integrate the Gigya service into their Flash application. Follow the steps below to get started, and use the Library Reference while implementing.

Note: Flash SDK requires Actionscript 3.

Note: If you wish to integrate the Gigya service in your server application, please refer to our Server Side SDKs and choose the SDK that suits your development platform. 


Library Guide

Please follow these steps to integrate Gigya's Flash library:

  1. Download the library archive:
  2. Gigya Setup - obtain your Gigya API key
  3. Add Gigya's Flash Library to your Flash project
  4. Initialize - create an instance of class GSAPI
  5. Login the User
  6. Use Gigya's API - Send Requests


Gigya Setup - Obtain Your Gigya API Key

Go to the Dashboard section on Gigya's website. Follow the instructions in the Gigya's Setup guide to setup your application and obtain a Gigya API key.

Important: Please make sure to check the Enable Mobile or Desktop Client Applications API Access checkbox in the Permissions page.

Adding Gigya's Flash Library to Your Flash Project

To get started, you'll need to add Gigya's Flash library to your application's project by doing the following:

  1. Drag the Gigya.Socialize.SDK.swc file into your application's Flash project.
  2. Import the Gigya package:
import com.gigya.socialize.*;

You should now be able to compile your project successfully.


Initialization - Create an Instance of the GSAPI Class

Class GSAPI is the central class of the Gigya Flash API. Instances of the GSAPI class provide access to the Gigya service.
As a first step for using Gigya service, create a new instance of GSAPI:

var gsAPI:GSAPI;


Class GSAPI has one constructor:

GSAPI(APIKey:String, stage:Stage)


  • apiKey - your Gigya API key, which you have obtained in the previous step.
  • stage - your stage.

You should create only one GSAPI object and retain it for the lifetime of your application.

Logging in the User

The first interaction with Gigya must always be logging in. If the user is not logged in, you cannot access her social profile nor perform social activities, such as setting her status. To implement logging-in use the login method of class GSAPI. In the following code sample we login the user to Facebook:

private function loginWithGigya():void 
      // Step 1: Define login parameters
      var loginParams:Object = { provider: 'facebook' };  // the login provider set to be Facebook

      // Step 2: Login the user to Facebook:
      gsAPI.login(loginParams, loginCallback);  // 1st parameter is mandatory, 2nd is optional

// Step 3 (optional): login's callback function 
private function loginCallback(method:String, response:GSResponse = null, context:*= null):void 
      if (response.getErrorCode() != 0)
            trace ("An error in the login: " + response.getLog());
      else {
            // handle response here...


The login method

The login method receives one required parameter and two optional:

login(params:Object, callback:Function = null, context:* = null):void
  • params:Object - an object that contains the parameters for the Gigya API method to call. The supported parameters are:
    • provider (mandatory) - the provider which will be used for authenticating the user. The following providers currently support the login operation: Facebook, Twitter, Yahoo, Microsoft Messenger, Google+, LinkedIn, AOL, FourSquare, Instagram, Renren, Tencent QQ, Sina Weibo, Kaixin, Vkontakte, WordPress, Blogger, Typepad, Paypal, Amazon, liveJournal, VeriSign, OpenID, Netlog, Signon, Orange France, mixi, Yahoo JAPAN, Odnoklassniki, Spiceworks, Livedoor, Skyrock, VZnet, WeChat, Xing.
    • cid (optional) - This string will appear on reports generated by Gigya, in the "Context ID" combo box.
  • callback:Function (default = null) — a callback function that will be invoked when the login process completes.
  • context:* (default = null) — a developer-created object that will be passed back unchanged to the callback function.

Callback Function (optional)

Using the callback function, you may receive a notification from Gigya when the login process concludes, and apply post login operations (such as updating the UI).

The callback function should have the following signature (function name may be altered):

function loginCallback(method:String, response:GSResponse = null, context:*= null):void
  • method: is the name of the method this callback is associated with.
  • response: is an object that wraps Gigya server's response (see usage examples below).
  • context: (default = null) an object that you have passed to the method this callback is associated with (see the login parameters above).

When executing the login method, pass the function reference as the second parameter:

gsAPI.login(loginParams, loginCallback);


Sending a Request

After you have logged in the user, you may use the  GSAPI to access the user profile and perform various activities. This is implemented using GSAPI's sendRequest method. The following code sends a request to set the current user's status to "I feel great":

protected function setStatusViaGigya():void
      // Step 1: Defining request parameters
      var params:Object = { status: "I feel great" };  // set the "status" parameter to "I feel great"

      // Step 2: Sending the request
      var methodName:String = "socialize.setStatus";
      gsAPI.sendRequest(methodName, params, false, setStatusCallback);    
// Step 3 (optional): define a callback function
private function setStatusCallback(method:String, response:GSResponse = null, context:*= null):void
       if (response.getErrorCode() != 0)
             trace ("An error in setStatus: " + response.getLog());
       else {
             // Handle response here...


Step 1: Define the Request Parameters

Create a Object instance and fill it with parameters. For example:

var params:Object = { param1:"value1", param2:"value2", param3:"value3",... };

You may find in the Example below, an example of a request with a complex object parameter.

Note: You can find the list of available Gigya API methods and the list of parameters per each method in the REST API reference


Step 2: Sending the Request

Execute the sendRequest method:

gsAPI.sendRequest(methodName, params, false, setStatusCallback);

The parameters of the method are:

  1. method: the Gigya API method name. Please refer to the REST API reference for the list of available methods.
  2. params: the parameters object that you have created in Step 1.
  3. useHTTPS: Boolean (default = false), whether to send the request via HTTPS.
  4. callback: a reference to a callback function that will be invoked when this operation completes (see next step).
  5. context - an optional object, that is passed back with the response.


Step 3: Callback Function (optional)

Define a callback function to handle the response received from Gigya:

private function setStatusCallback(method:String, response:GSResponse = null, context:*= null):void
       if (response.getErrorCode() != 0)
             trace ("An error in setStatus: " + response.getLog());
       else {
             // Handle response here...


The GSResponse object includes data fields. For each request method the response data fields are different. Please refer to the Gigya REST API reference for the list of response data fields per method.
For example - handling a 'getUserInfo' response:
The response of 'getUserInfo' includes a 'user' object.

private function setStatusCallback(method:String, response:GSResponse = null, context:*= null):void
       if (response.getErrorCode() != 0)
             trace ("An error in setStatus: " + response.getLog());
       else {        
             var nickname:String = response.getString("nickname","");  // Second parameter receives default value
             var age:String = response.getInt("age", 0);
             trace ("User name: " + nickname + "; The user's age: " + age);


Example - Publish User Action

The following code sample sends a request to publish a user action to the newsfeed stream on all the connected providers that support this feature.

The socialize.publishUserAction method has a complex parameter called userAction, which defines the user action data to be published. To define the userAction parameter you can use compound Objects, as shown in the example below:

// 1. Defining request parameters 
var userAction:Object = {title: "This is my title", userMessage: "This is a user message", description: "This is a description",
      linkBack: "http://google.com", mediaItems: [ {src: "http://www.f2h.co.il/logo.jpg", href: "http://www.f2h.co.il", type: "image"}]};

var params:Object = {userAction: userAction};  // set the "userAction" parameter 

// 2. Sending 'socialize.publishUserAction' request 
gsAPI.sendRequest("socialize.publishUserAction", params);


To learn more about publishing user actions, please read the Advanced Sharing guide.



Appendix - Verifying Signatures from Mobile Logins

The process for verifying UID signatures generated from logins via our mobile SDKs depends on whether the client is using an older (2_xxx) API key or a newer (3_xxx) API key.

For older API keys the process is as follows:

  1. Upon user login, grab the "accessToken" and "secret" from the getSession method of GSSession in your mobile SDK.
  2. Over HTTPS, pass this accessToken and secret to your application server.
  3. Call getUserInfo (without specifying a UID) passing the accessToken and secret as the API Key and Secret Key (respectively) to the Gigya API.
  4. Assuming the accessToken and secret that you received in iOS is valid, you will receive a valid response from the getUserInfo call.

For newer API keys the process is as follows:

  1. Upon user login, grab the UID, Signature, and Timestamp from the response and pass it to your application server.
  2. Use your SDK's SigUtils.validateUserSignature() method, passing in the data you received from step 1 and your Gigya secret key.
Page statistics
1351 view(s) and 2 edit(s)
Social share
Share this page?


This page has no custom tags.
This page has no classifications.


You must to post a comment.