I’ve used that approach and it works fine–however, the reason why I’m trying to call the API using the second approach is for better response time. I have Piwik installed on the same server and it doesn’t make sense for me to call the API over http… when I do, the response time is dramatically affected
Piwik doesn’t have a ‘Controller’ class. I’m guessing this is from CodeIgniter. In which case, check your include path, autoloader, and/or current working directory (in case, CodeIgniter uses relative include paths).
hi anthon–i did that–it works fine if I dont use the approach below–but when I do, codeigniter and piwik doesn’t seem to interact very well causing the error… =/
<?php
// if you don't include 'index.php', you must also define PIWIK_DOCUMENT_ROOT
// and include "libs/upgradephp/upgrade.php" and "core/Loader.php"
define('PIWIK_INCLUDE_PATH', realpath('..'));
define('PIWIK_USER_PATH', realpath('..'));
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";
Piwik_FrontController::getInstance()->init();
// This inits the API Request with the specified parameters
$request = new Piwik_API_Request('
method=UserSettings.getResolution
&idSite=7
&date=yesterday
&period=week
&format=XML
&filter_limit=3
&token_auth=anonymous
');
// Calls the API and fetch XML data back
$result = $request->process();
echo $result;
I am having the same issue. I am using Codeigniter. I have created installed Piwik outside the application folder. I can’t figure it out the API. Please share your knowledge if you have solved this issue.