Skip to content

Instantly share code, notes, and snippets.

@jwcobb
Last active December 24, 2015 12:59

Revisions

  1. jwcobb renamed this gist Oct 2, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. jwcobb created this gist Oct 2, 2013.
    98 changes: 98 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,98 @@
    require_once 'Zend/Loader/Autoloader.php';
    $autoloader = Zend_Loader_Autoloader::getInstance();
    $autoloader->registerNamespace('Zend_');
    $autoloader->registerNamespace('Ticketevolution_');
    $autoloader->setFallbackAutoloader(false);


    $cfg['params']['apiToken'] = (string) 'TOKEN';
    $cfg['params']['secretKey'] = (string) 'KEY';
    $cfg['params']['apiVersion'] = (string) '9';
    $cfg['params']['buyerId'] = 'BUYERID';
    $cfg['params']['baseUri'] = (string) 'https://api.ticketevolution.com';;

    $tevoClient = new \TicketEvolution\Webservice($cfg['params']);

    $performerSearchName = (string) 'Depeche Mode';
    $options = array(
    'page' => 1,
    'per_page' => 1,
    );

    try {
    $performers = $tevoClient->searchPerformers($performerSearchName, $options);
    } catch(\TicketEvolution\ApiInvalidRequestException $e) {
    // Invalid parameters were supplied

    // Put something here to gracefully handle this situation

    } catch (\TicketEvolution\ApiAuthenticationException $e) {
    // Authentication with the API failed

    // Put something here to gracefully handle this situation

    } catch (\TicketEvolution\ApiConnectionException $e) {
    // Network communication failed

    // Put something here to gracefully handle this situation

    } catch (\TicketEvolution\ApiException $e) {
    // Something went wrong with the request

    // Put something here to gracefully handle this situation

    } catch (\Exception $e) {
    // Something else happened, probably unrelated to TicketEvolution

    // Put something here to gracefully handle this situation

    }

    if (count ($performers) > 0) {
    $performer_id = $row->id;
    $optionsEvents = array(
    'page' => 1,
    'per_page' => 100,
    'performer_id' => $performers->current()->id,
    'primary_performer' => 'true',
    );

    try {
    $events = $tevoClient->listEvents($optionsEvents);
    } catch(\TicketEvolution\ApiInvalidRequestException $e) {
    // Invalid parameters were supplied

    // Put something here to gracefully handle this situation

    } catch (\TicketEvolution\ApiAuthenticationException $e) {
    // Authentication with the API failed

    // Put something here to gracefully handle this situation

    } catch (\TicketEvolution\ApiConnectionException $e) {
    // Network communication failed

    // Put something here to gracefully handle this situation

    } catch (\TicketEvolution\ApiException $e) {
    // Something went wrong with the request

    // Put something here to gracefully handle this situation

    } catch (\Exception $e) {
    // Something else happened, probably unrelated to TicketEvolution

    // Put something here to gracefully handle this situation

    }

    }

    if (isset($events) && !empty($events)) {
    foreach ($events as $event) {
    $eventDateTime = new \TicketEvolution\DateTime($event->occurs_at);
    echo '<p>' . $event->name . ' at ' . $event->venue->name . ' at ' . $eventDateTime->formatTbaSafe(\TicketEvolution\DateTime::DATETIME_FULL_NOTZ) . '</p>' . PHP_EOL;
    }
    } else {
    echo '<p>Sorry, there are not currently events for ' . $performerSearchName . '</p>' . PHP_EOL;
    }