Example #1
0
The --sampling-level argument provides a way to express a preference regarding the degree of
sampling in the Google Analytics data. If the option "none" is used, the report will be treated
as having failed if Google reports sampling as being present in the results; in this case the user
must specify a shorter time interval in the --split-queries-by option in order to avoid data
sampling.

The --formatter argument may be used to specify the name of a PHP class that inherits from
Google\\Analytics\\ReportFormatter; an instance of this class will be used to format the report's
contents.

The --name argument only makes sense when emailing a report; it allows for the specification of a
meaningful name to describe the report's contents.

The --group-name argument fulfills a similar function to the --name argument, but applies when
including multiple reports in the same file, and will be used to describe the entire collection.
This argument is ignored if specified when running only a single report.

EOF
);
require_once __DIR__ . DIRECTORY_SEPARATOR . 'bootstrap.php';
try {
    try {
        $args = PFXUtils::collapseArgs(array(), array('profile-name:', 'profile-id:', 'metric:', 'start-date:', 'end-date:', 'email:', 'file:', 'dimension:', 'sort:', 'limit:', 'filter:', 'segment:', 'split-queries-by:', 'date-format-string:', 'sampling-level:', 'name:', 'group-name:', 'formatter:', 'conf:', 'help'));
        $ga = new Google\Analytics\API();
        Google\Analytics\QueryConfiguration::createFromCommandLineArgs($args)->run($ga);
    } catch (InvalidArgumentException $e) {
        PFXUtils::printUsage($e->getMessage(), 1, true);
    }
} catch (Exception $e) {
    echo PFXUtils::buildExceptionTrace($e) . "\n";
}
PFX_SHORT_USAGE_MESSAGE. */
require_once __DIR__ . DIRECTORY_SEPARATOR . 'PFXUtils.class.php';
try {
    $modifiers = new SplStack();
    while ($argv) {
        $arg = array_pop($argv);
        if ($arg == '--') {
            break;
        }
        $modifiers->push($arg);
    }
    $args = unserialize($modifiers->pop());
    if ($args === false) {
        throw new RuntimeException('Could not unserialize the first item in the argument vector.');
    }
    try {
        define('PFX_USAGE_MESSAGE', $modifiers->pop());
        try {
            define('PFX_SHORT_USAGE_MESSAGE', $modifiers->pop());
        } catch (RuntimeException $e) {
            // Short message was not passed
        }
    } catch (RuntimeException $e) {
        // Message was not passed
    }
    $parsedArgs = call_user_func_array(array('PFXUtils', 'collapseArgs'), $args);
    echo serialize($parsedArgs);
    exit(0);
} catch (Exception $e) {
    PFXUtils::printUsage(sprintf('%s: %s', get_class($e), $e->getMessage()), 1, true);
}