$config = loadConfig(); // Instantiate API class: $acuity = new AcuityScheduling(array('userId' => $config['userId'], 'apiKey' => $config['apiKey'], 'base' => $config['base'])); $engine = new \Handlebars\Handlebars(array('loader' => new \Handlebars\Loader\FilesystemLoader(__DIR__, array('extension' => '.html')))); $method = $_SERVER[REQUEST_METHOD]; if ($method === 'GET') { $start = true; $_SESSION['appointmentType'] = null; $_SESSION['date'] = null; $_SESSION['time'] = null; } if ($method === 'POST') { // Start of the flow: if (!$_POST) { // Fetch appointment types: $appointmentTypes = $acuity->request('/appointment-types'); $_SESSION['appointmentTypes'] = $appointmentTypes; } elseif ($_POST['appointmentTypeID']) { // Appointment type selected: foreach ($_SESSION['appointmentTypes'] as $appointmentType) { if ($_POST['appointmentTypeID'] == $appointmentType['id']) { $_SESSION['appointmentType'] = $appointmentType; break; } } // Time to select a date: $month = strftime('%Y-%m'); $dates = $acuity->request("/availability/dates?month={$month}&appointmentTypeID={$_SESSION['appointmentType']['id']}"); } elseif ($_POST['date']) { // Date selected. Now select a time: $date = $_SESSION['date'] = $_POST['date'];
<?php require_once __DIR__ . '/../../src/AcuityScheduling.php'; require_once '../utils.php'; // Config: $config = loadConfig(); list($method, $path) = getRouteInfo(); // Instantiate API class: $acuity = new AcuityScheduling(array('userId' => $config['userId'], 'apiKey' => $config['apiKey'], 'base' => $config['base'])); // Example app: if ($method === 'GET' && $path === '/') { include 'index.html'; $response = $acuity->request('/me'); echo '<h1>GET /api/v1/me:</h1>'; echo '<pre>'; echo print_r($response, true); echo '</pre>'; $response = $acuity->request('/blocks', array('method' => 'POST', 'data' => array('start' => '2015-12-24', 'end' => '2015-12-26', 'calendarID' => 1, 'notes' => 'Christmas!'))); echo '<h1>POST /api/v1/blocks:</h1>'; echo '<pre>'; echo print_r($response, true); echo '</pre>'; $response = $acuity->request('/appointments', array('query' => array('max' => 1))); echo '<h1>GET /api/v1/appointments?max=1</h1>'; echo '<pre>'; print_r($response); echo '</pre>'; } else { handle404(); }