Api


(porto) #1

Hello,
I have been trying to get data from piwik using API, i used code below, but it ended up with message that plugin is not activated (while it is) should i initialize piwik somehow? When i called Piwik_FrontController::getInstance()->init();
it ended up with lots of errors…and so did require_once(PIWIK_INCLUDE_PATH . “/index.php”);

            include(PIWIK_INCLUDE_PATH.'/core/Loader.php');
            spl_autoload_register(array('Piwik_Loader','autoload'));

$request = new Piwik_API_Request('
            method=UserCountry.getCountry
            &idSite=1
            &date=today
            &period=day
            &format=html 
            
            &token_auth=c0e024d9200b5705bc4804722636378a
');
        var_dump($request);
$this->data = $request->process();
        spl_autoload_unregister(array('Piwik_Loader','autoload'));

However using API over http works fine and i am getting data…thx for any answer…


(Matthieu Aubry) #2

check out the doc “Calling Piwik API from PHP”: http://dev.piwik.org/trac/wiki/API/Calling…s#FromwithinPHP