// we'll store the accessToken in the session for future page visits.
$acuity = new AcuitySchedulingOAuth(array('accessToken' => $_SESSION['accessToken'], 'clientId' => $config['clientId'], 'clientSecret' => $config['clientSecret'], 'redirectUri' => $config['redirectUri'], 'base' => $config['base']));
// Example app:
if ($method === 'GET' && $path === '/') {
    include 'index.html';
    // If we're already connected, make a request:
    $response = $acuity->request('me');
    echo '<h1>GET /api/v1/me:</h1>';
    echo '<pre>';
    print_r($response);
    echo '</pre>';
} else {
    if ($method === 'GET' && $path === '/authorize') {
        // Redirect the user to the Acuity authorization endpoint.  You must
        // choose a scope to work with.
        $acuity->authorizeRedirect(array('scope' => 'api-v1'));
    } else {
        if ($method === 'GET' && $path === '/oauth2') {
            // Exchange the authorizatoin code for an access token and store it
            // somewhere.  You'll need to pass it to the AcuitySchedulingOAuth
            // constructor to make calls later on.
            $tokenResponse = $acuity->requestAccessToken($_GET['code']);
            if ($accessToken = $tokenResponse['access_token']) {
                $_SESSION['accessToken'] = $accessToken;
            }
            // Token response:
            echo '<h1>Token Response:</h1>';
            echo '<pre>';
            print_r($tokenResponse);
            echo '</pre>';
            // Current Access Token: