Last active
December 24, 2015 12:59
-
-
Save jwcobb/6801475 to your computer and use it in GitHub Desktop.
Search performer and list events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment