VEA API Connect

Helper class for VEA interaction with PHP

Download

You can download the code from github repo page here.

How to use

Constructor

VeaApiConnect($server_url, $user, $pass, $insecure = false)

Parameters

Return value

Returns a new instance of the VEA API Connect class.

Public methods

load

Loads data from VEA API in different formats.

VeaApiConnect::load( $api_uri, $params)

Parameters

Return value

Returns the result of the API request. The format of the response depends on the extension used in the URI. The available formats are listed in the following table:

URI Extension Response data format
pc8 PHP variable dump. Must be decoded using PHP eval function.
ps8 PHP serialized data. Can be decoded using PHP unserialize function.
json JSON. Can be decoded with PHP json_decode function.

This function performs a CURL POST request to get the response.

Examples

Get events data in JSON:

<?php
include_once 'vea-api-connect.php';
// set connection values
$server_url = "https://venueeventartist.com";
$user = "1234";
$pass = "4d37a7c2b52723235a5d8c1554ba9a97f697922a";
// create new instance
$vea_api = new VeaApiConnect($server_url, $user, $pass);
// set request parameters
$params = array(
    'venuetype' => 1017,
    'marketareaid' => 446,
    'eventtype' => 1100,
);
// load events data
$data = $vea_api->load("/api/v1/events/events.json", $params);
// decode JSON into associative array
$data = json_decode($data, true);
// Use the events data
foreach($data['events'] as $event) {
    echo $event['name']."\n";
    echo $event['date']."\n";
    echo $event['descr']."\n";
}

To change the format of the response to serialized PHP data, the URI extension must be changed from json to ps8 and the decoding method changes also:

$data = $vea_api->load("/api/v1/events/events.ps8", $params);
$data = unserialize($data);