Commencer un nouveau sujet

PHP | Reseller API: how to get a list of all appointments taking place last month

You can extract all appointments from previous month, along with their date and associated service :


<?php 
$apiKey = "";
$ssoToken = "";
$clients = json_decode(file_get_contents("https://api.agendize.com/api/2.0/resellers/accounts?apiKey=$apiKey&token=$ssoToken"));

$startDate = date("Y-m-d\T00:00:00P", strtotime('first day of previous month'));
$endDate = date("Y-m-d\T23:59:59P", strtotime('last day of previous month'));

echo "Account\tStart\tEnd\tService\n";
foreach ($clients->items as $client) {
    if ($client->status == "enabled") {
        $companies = json_decode(file_get_contents("https://api.agendize.com/api/2.1/scheduling/companies?apiKey=$apiKey&token=" . $client->ssoToken));
        $companyId = 0;
        if ($companies != null) {
            foreach ($companies->items as $company) {
                // @todo: Please note that next syncToken's page might be retrieved as well
                $appointments = json_decode(file_get_contents("https://api.agendize.com/api/2.1/scheduling/companies/$company->id/appointments?startDate=$startDate&endDate=$endDate&apiKey=$apiKey&token=" . $client->ssoToken));

                foreach ($appointments->items as $appointment) {
                    echo $client->email . "\t";
                    $datetime = explode("T", $appointment->start->dateTime);
                    echo $datetime[0] . "\t";
                    echo $datetime[1] . "\t";
                    echo $appointment->service->name . "\n";
                }
            }
        }
    }
}
?>


Connexion ou Inscription pour poster un commentaire