ipernity/ FLASH ACTIONSCRIPT 3 API Kit (v0.9)

This FLASH ACTIONSCRIPT 3 API Development Kit requires a Flash CS3 or an Adobe Flex environment. This toolkit provides some basic functions to perform API calls. Results can be returned in JSON or XML.

Keep your API secret safe.

Installation

Download Iper_API-latest.zip, unzip and copy the com directory into your Flash source directory.

Demo

In the demo directory, you could find a fla script for testing a simple request (doc.search method).

demo_request.fla

import com.ipernity.api.IperAPI;


/**
 * API configuration
 *     api_key (String)      : (needed)   your API key
 *     api_secret (String)   : (optional) your API secret
 *     format (String)       : (needed)   response format : json or xml
 *     raw_response (String) : (needed)   raw data response (json/xml String) or Object (for json format) / XML (for xml format)
 */
var conf:Object = {
   api_key      : ""
  ,api_secret   : ""
  ,format       : "xml"
  ,raw_response : false
}


/**
 * create API instance
 */
var iperAPI:IperAPI = new IperAPI( conf );


/**
 * parameters for the doc.search method
 */
var params:Object = {
   tags      : "test"                   // search docs with "test" tag
  ,media     : "photo"                  // only photos
  ,thumbsize : "240"                    // only 240 width photos
  ,per_page  : "10"                     // 10 photos maximum
}


/**
 * doc.search method callback
 *     succes (Boolean) : true if status="ok", false otherwise.
 *     response (*)     : xml or json response
 *     loader (Object)  : loader used for request. Object members :
 *                           method (String)        : API method called
 *                           url (String)           : URL called
 *                           params (Object)        : parameters sended
 *                           callback (Function)    : callback function
 *                           format (String)        : format of the response
 *                           raw_response (Boolean) : response in raw format ?
 */
function docSearchRsp( succes:Boolean, response:*, loader:Object )
{
  /** result of the doc.search method */
  if( succes ) {
    // ...
  } else {
    // ...
  }
}


/**
 * execute the doc.search method
 *     method (String)         : API method to call.
 *     params (Object)         : parameters to send. no need to add 'api_key'.
 *     callback (Function)     : function to execute when the request completes.
 *     withAuthToken (Boolean) : add auth_token ?
 */
iperAPI.request( "doc.search", params, docSearchRsp, false );

Methods

function IperAPI(Object conf)

The class constructor. Uses _setConf(conf) to set configuration values.

function request(String method, Object params, Function callback, Boolean withAuthToken)

Parameters :

function setAuthToken()

Save the authentication token.

One last thing...

Have fun and let us know if you need any help.