Currently data can be pushed in the database using the piwik.php script, called from the piwik.js tag.
However in some cases we want to push statistics from within PHP or other languages. For example, if we want to count all hits on a given file (for example http://piwik.org/last.zip) this file could instead be a script issuing a request to record a new download, and then redirect the user to the actual file requested.
In php the file last.zip could be a PHP file with the content:
<?php
// this file will record the download and then redirect the user to the file
// we first call the PIWIK push API in order to record this download
Piwik_LogStats_API::logNewDownload('last.zip');
// we load the requested file so the user can download it
readfile('files/last.zip'); // see php.net/readfile
?>
Next steps:
- list use cases for such an API
- specify an API based on use cases
- implement reusing /refactoring existing code in the LogStats* classes.