$credentials['app_key'], 'secret' => $credentials['app_secret'], ]); print_r($result); $authToken = $result['authToken']; // events $result = callApi($apiBaseUrl. '/events', $authToken, [ 'includeSoldOut' => true, 'includeVenueOnly' => true, ]); print_r($result); // get tickets for first event $eventId = $result['events'][0]['id']; $result = callApi($apiBaseUrl. '/tickets', $authToken, [ 'authToken' => $authToken, 'eventId' => $eventId, ]); print_r($result); } catch (Exception $e) { echo $e->getMessage(), PHP_EOL; exit -1; } function callApi($url, $authToken, $data) { echo $url. PHP_EOL; $ch = curl_init($url); $data_json = json_encode($data); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $headers = [ 'Content-Type: application/json', 'Content-Length: '. strlen($data_json), ]; if ($authToken) { $headers[] = 'Authorization: Bearer '. $authToken; } curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); if ($result === false) { die('cURL error: ' . curl_error($ch). PHP_EOL); } $result = json_decode($result, true); if (isset($result['error'])) { throw new Exception("API error: [{$result['error']}] {$result['message']}"); } return $result; }