Ejemplo n.º 1
0
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
require_once '../utils.php';
// Config:
$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:
Ejemplo n.º 2
0
<?php

require_once __DIR__ . '/../../src/AcuityScheduling.php';
require_once '../utils.php';
// Config:
$config = loadConfig();
$secret = $config['apiKey'];
list($method, $path) = getRouteInfo();
// App:
if ($method === 'GET' && $path === '/') {
    include 'index.html';
} else {
    if ($method === 'POST' && $path === '/webhook') {
        // Handle webhook after verifying signature:
        try {
            AcuityScheduling::verifyMessageSignature($secret);
            error_log("The message is authentic:\n" . json_encode($_POST, JSON_PRETTY_PRINT));
        } catch (Exception $e) {
            trigger_error($e->getMessage(), E_USER_WARNING);
        }
    } else {
        handle404();
    }
}
Ejemplo n.º 3
0
<?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();
}