Setup
API Account Key Setup
The first step is to request an API account key from support. When requesting a key, please ensure that you specify whether you want a master key (all access key) or a non-master key (which has the ability to have a controlled level of access.) Please note, you can only have one master key per account. Once your key is created, navigate to the Settings > Account Settings > Integrations page. Once there, click the edit icon next to the key you would like to modify.

You will be able to customize your API Account Key by:

  1. Choosing a key Label (non-master only).
  2. Defining which IP addresses will be able to access the API using the key.
  3. Choosing an expiration period.
  4. Choosing the events which the API Account Key will have access to (non-master only).

Non-Master keys will default to having no access to any events in your account. You will have to attach the events which you want the key to have permissions to. Currently, event restrictions are enforced in the Global and registration APIs only – information related to any event in the marketing, networking, surveys and eSelect APIs will still be available to any API Account Key.

Making Requests
The Aventri API is a REST web service and can be called using HTTP requests. If you want to use PHP, you can use cURL. The PHP code sample below is an example of a wrapper class to call the API and return either XML or JSON. The API can be accessed via other programming languages as well. PHP is provided as an example.

- By August 2016, we updated the Sample Code below, 
1. It added the new param for 'request()' function. 
request($request, $module = 'ereg', ... );
Available modules: 'ereg', 'esocial', 'eselect', 'global', 'emarketing', 'eseating', 'esurvey'; 'global' is default;

2. It enforced the SSL Verification. 
You'll need to get your CA's cert and point curl at it. More details at cURLS's Details on Server SSL Certificates. https://curl.haxx.se/docs/sslcerts.html

Example steps you can try, set cacert.pem to curl.cainfo.
Since PHP 5.3.7 you could do:
    1>.download https://curl.haxx.se/ca/cacert.pem and save it somewhere.
    2>.update php.ini — add the line: curl.cainfo = "PATH_TO/cacert.pem"
OR
    you can do the following for every cURL resource: 
curl_setopt($ch, CURLOPT_CAINFO, "PATH_TO/cacert.pem"); 

---------------------------------------------------------------------------------------------------

class etouchesAPIv2 {
protected $accessToken;
protected $baseURL;
protected $functions = array();
protected $format = 'json';

  public function __construct($accountid, $key, $baseURL = 'https://www.eiseverywhere.com')
  {
               $this->baseURL = rtrim($baseURL,'/').'/api/v2/';
               $request = $this->rawRequest($this->baseURL.'global/authorize.json', 
                                                                     array('accountid'=>$accountid'key'=>$key));
               $response = json_decode($request['response'], true);
               if (empty($response['accesstoken'])) {
                 throw new \Exception(__CLASS__.': Bad url or parameters given. '.print_r($response,1));
      }

               $this->accessToken = $response['accesstoken'];
               $response = $this->rawRequest($this->baseURL.'global/listAvailableFunctions.json',
               array('accesstoken' => $this->accessToken));
             $functions = json_decode($response['response'], true);
             foreach ($functions as $sectionName=>$section) {
           foreach ($section as $methodName=>$functionArray) {
                foreach ($functionArray as $functionName) {
                     $this->functions[$sectionName][strtolower($functionName)] = array('method'=>$methodName, 'section'=>$sectionName);
           }
        }
      }
}

public function setFormat($format)
{
    $validFormats = array('xml','json');
    if (! in_array($format, $validFormats)) {
        $message = __CLASS__.": Invalid format: $format. Not one of the following:";
        foreach ($validFormats as $value) {
            $message .= ' '.$value;
        }
        throw new \Exception($message);
    }
    $this->format = $format;
}

public function request($request, $module = 'global', $parameters = array())
{
  $module = strtolower($module);
  $request = strtolower($request);
    $parameters['accesstoken'] = $this->accessToken;
    if (! array_key_exists($request, $this->functions[$module])) {
        return array(
                   'response' => '',
                   'info' => $this->functions,
                   'errors' => "Unknown function: $request",
                );
    }
    $function = $this->functions[$module][$request];
    $url = $this->baseURL.$function['section'].'/'.$request.'.'.$this->format;
    return $this->rawRequest($url, $parameters, $function['method']);
}

public static function rawRequest($url, $parameters = array(), $method = 'get')
{
      $response = 'Unable to use etouches API, please enable cURL functionality (http://php.net/curl) for your server and try again';
      $info = '';
      $errors = '';
      $method = strtolower($method);
      if (function_exists('curl_init')) {
            $ch = curl_init();
            $paramString = http_build_query($parameters);
            if ($method == 'get') {
                curl_setopt($ch, CURLOPT_URL, $url . (!empty($paramString)?'?'.$paramString:''));
            } else { 
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_POST, true);
            }
            if ($method == 'post') {
                  foreach ($parameters as &$value) {
                         if (is_array($value)) {
                              $value = http_build_query($value);
                         }
                  }
                  curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
            } else if ($method == 'put') {
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                  curl_setopt($ch, CURLOPT_CUSTOMREQUEST,$method);
                  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen($paramString)));
                  curl_setopt($ch, CURLOPT_POSTFIELDS, $paramString);
            }

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
            curl_setopt($ch, CURLOPT_TIMEOUT, 30);

            $response = curl_exec($ch);
            $info = curl_getinfo($ch);
            $errors = curl_error($ch);
            curl_close($ch);
      }

      return array(
            'response' => $response,
            'info' => $info,
            'errors' => $errors
      );
}

}

function dump($h1, $var)
{
      echo "$h1";
      var_dump($var);
}
$api = new etouchesAPIv2($yourAccountId, $yourAPIKey);
//Available modules: 'ereg', 'esocial', 'eselect', 'global', 'emarketing', 'eseating', 'esurvey'; 'global' is default;
$response = $api->request($call = 'listFolders', $module = 'global'); $folders = json_decode($response['response'], true); dump($call, $folders);

$parameters = array('name' => "New event created by etouches API",
'modules' => array('eHome','eMobile','eSelect','eReg','eBooth','eConnect','eSocial','eSeating'),);
if (count($folders)) {
      $parameters['folder'] = $folders[0]['folderid'];
}

$api->setFormat('xml');
$response = $api->request($call = 'createEvent', $module = 'ereg',  $parameters);
$newEvent = new SimpleXMLElement($response['response']);
dump($call, $newEvent);

$api->setFormat('json');
$response = $api->request($call = 'listEvents', $module = 'global');
$events = json_decode($response['response'], true);
dump($call, $events);

$api->setFormat('xml');
$response = $api->request($call = 'listSpeakers', $module = 'ereg', array('eventid' => $events[0]['eventid']));
$speakers = new SimpleXMLElement($response['response']);
dump($call, $speakers);

$response = $api->request($call = 'getEvent', $module = 'ereg', array('eventid' => $events[0]['eventid']));
$event = new SimpleXMLElement($response['response']);
dump($call, $event);

$response = $api->request($call = 'cloneEvent', $module = 'global', array('eventid' => $events[0]['eventid'],'name'=>"Event cloned via etouches API"));
$clonedEvent = new SimpleXMLElement($response['response']);
dump($call, $clonedEvent);

At this stage you are now ready to start using our API. We support return values encoded via JSON or XML.  Specify the return value by substituting .xml or .json for .function in the Resource URL. The first API call you should make is to authenticate yourself. Once you are authenticated and you have your session key, you can then start utilizing the rest of the Aventri API.

Enjoy!