@Kiusau wrote:
Although I have had little trouble making report requests to the Matomo program via HTTP requests, I am having enormous trouble in my effort to access the same directly via PHP.
I copied, with some modification, the sample code (see below) provided by Matomo into a file. When I try to open the file, however, I am confronted with the following error message.
Please contact the system administrator, or login to Matomo to learn more. If you are Super User, but cannot login because of this error, you can still troubleshoot further. Follow these steps: 1) open the config/config.ini.php file and look for the salt value under [General]. 2) edit this current URL you are viewing and add the following text (replacing salt_value_from_config by the salt value from the config file): index.php?i_am_super_user=salt_value_from_config&....
Following this advice does not resolve the problem, however.
The ERROR MESSAGE
Please contact the system administrator, or login to Matomo to learn more.
If you are Super User, but cannot login because of this error, you can still troubleshoot further. Follow these steps:
- open the config/config.ini.php file and look for the salt value under [General].
- edit this current URL you are viewing and add the following text (replacing salt_value_from_config by the salt value from the config file):
index.php?i_am_super_user=salt_value_from_config&…
The CODE
<?php ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log'); ini_set('html_errors', 0); ini_set('display_errors', 0); error_reporting(E_ALL); use Matomo\API\Request; use Matomo\FrontController; define('PIWIK_INCLUDE_PATH', realpath('my_path')); define('PIWIK_USER_PATH', realpath('my_path')); define('PIWIK_ENABLE_DISPATCH', false); define('PIWIK_ENABLE_ERROR_HANDLER', false); define('PIWIK_ENABLE_SESSION_START', false); require_once PIWIK_INCLUDE_PATH . "/index.php"; require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php"; $environment = new \Piwik\Application\Environment(null); $environment->init(); FrontController::getInstance()->init(); // This inits the API Request with the specified parameters $request = new Request(' module=API &method=Resolution.getResolution &idSite=1 &date=yesterday &period=week &format=original &filter_limit=3 '); // Calls the API and fetch XML data back $result = $request->process(); echo $result; ?>
Any suggestions about how to implement PHP Direct?
Roddy
Posts: 3
Participants: 1