I am having problems with using the API. I am trying to include some API calls into a Yii framework application but i get the following error: session has already been started by session.auto-start or session_start()
I did a forum search, checked that the folders are writable,session.auto_start 0, etc. Same results.
Tested the solution found here still get the error.
When I call the file outside of the Yii app everythings works ok, but now within the application.
Code below:
Any clues ?
I did a forum search, checked that the folders are writable,session.auto_start 0, etc. Same results.
Tested the solution found here still get the error.
When I call the file outside of the Yii app everythings works ok, but now within the application.
Code below:
<?php use Piwik\API\Request; use Piwik\FrontController; define('PIWIK_INCLUDE_PATH', realpath('\wamp\www\piwik')); define('PIWIK_USER_PATH', realpath('\wamp\www\piwik')); 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"; // if you prefer not to include 'index.php', you must also define here PIWIK_DOCUMENT_ROOT // and include "libs/upgradephp/upgrade.php" and "core/Loader.php" FrontController::getInstance()->init(); // This inits the API Request with the specified parameters function piwikRequest($piwikSiteId,$piwikMethod,$piwikPeriod,$piwikDate) { $piwikGetData = new Request (' method='. $piwikMethod .' &idSite='. $piwikSiteId .' &period='. $piwikPeriod .' &date='. $piwikDate .' &segment=customVariableName1==Mailing &format=php &serialize=1 &token_auth=token '); $piwikGetData = $piwikGetData->process(); return $piwikGetData; } ?> <?php function vizite() { $piwik = piwikRequest('1','VisitsSummary.getVisits','month','last1'); $arr = unserialize($piwik); $vizite= reset($arr); echo $vizite; } ?>
Any clues ?