function main($argc, $argv) { // Reset to 0 upon success $rc = 1; // 3 args (+progname) required if ($argc != 4) { usage(); printf("ERROR: 3 args required.\n"); } else { // Store args $commandLine = new CommandLine_sgstats2phone($argc, $argv); // Extract args $commandLine->extractArgs(); // Validate args if (($argStatus = $commandLine->validateArgs()) != 0) { usage(); $commandLine->printArgErrorMessage($argStatus); } else { // Store the args in the sendGrid object $sendGrid = new SendGrid($commandLine->argPhone, $commandLine->argUser, $commandLine->argApiKey); // MySecretApiKey // Get the SendGrid stats for the current day (via REST/XML) if ($sendGrid->statsGet() != 0) { printf("ERROR: sendGrid->statsGet()\n"); } else { // Assemble the text-to-speech text, setup params to pass to curl $sendGrid->assembleStats(); // Send stats to phone if (SendGridCurl::issueRequest($sendGrid->get_statsParams()) == 0) { // Successful $rc = 0; } } } } exit($rc); }