<?php

session_start();
require_once '../vendor/autoload.php';
$user_email = '';
$user_password = '';
$client_id = '';
$client_secret = '';
$redirect_uri = 'https://mysite.local/oauth_redirect';
$company_id = 45;
$environment = \Spredfast\CustomSolutions\Conversations\AnalyticsExportAPI::ENV_APP3;
$auth = new \Spredfast\CustomSolutions\OAuth\Example\ExampleAuth($user_email, $user_password, $client_id, $client_secret, $redirect_uri);
$access_token = $auth->getAccessToken();
if (!$access_token) {
    $access_token = $auth->authorize();
}
/**
 * Get last updated date
 */
$exporter = new \Spredfast\CustomSolutions\Conversations\AnalyticsExportAPI($auth, $company_id, $environment);
$last_updated_data = $exporter->lastUpdate();
/**
 * Show list of available reports
 */
$list = $exporter->reports();
foreach ($list as $report) {
    echo $report->title;
}
/**
 * Download report
 */