how to set up a direct piwik API calling in php

I tried to do it this way but it gives this error: Fatal error: Class 'Piwik_FrontController' not found in C:\wamp\www\aqar2\piwik.php on line 11

my website path is :localhost/aqar2 my piwik path is: localhost/aqar2/piwik

<?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('.localhost/aqar2/.')); define('PIWIK_USER_PATH', realpath('.localhost/aqar2/.')); define('PIWIK_ENABLE_DISPATCH', false); define('PIWIK_ENABLE_ERROR_HANDLER', false); define('PIWIK_ENABLE_SESSION_START', false); require_once PIWIK_INCLUDE_PATH . "piwik/index.php"; require_once PIWIK_INCLUDE_PATH . "piwik/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=1 &date=yesterday &period=week &format=XML &filter_limit=3 &token_auth=&token_auth=a688c5c011dac27cf125eaa84f95e59b '); // Calls the API and fetch XML data back $result = $request->process(); echo $result; ?>

-------------Problems Reply------------

If your php file is in localhost/aqar2/then the path must be define('PIWIK_INCLUDE_PATH', realpath('piwik/'));

I know you probably fixed it already so i am adding that for whoever may need it...

That error is a result of a class being used (or referenced) but not yet loaded. This is likely a result of your PIWIK_INCLUDE_PATH being incorrectly set, or that you are required to include the class yourself.

First, double check that the value set in your PIWIK_INCLUDE_PATH is a valid path on the system, perhaps with:

if (is_dir(PIWIK_INCLUDE_PATH)) {
exit('IT IS A REAL PATH');
} else {
exit('IT IS NOT A REAL PATH');
}

If it turns out to not be a real path, perhaps you should look at the '.' dot prefix on your 'localhost' directory. Do you not mean to use realpath('localhost/aqar2/piwik');. If that does work, you should also look at how you've set PIWIK_USER_PATH.

If that does not work, you should look at including the FrontController class yourself, but this may mean that you have to manually include all of that classe's dependencies as well. To include the class manually, use include(PIWIK_INCLUDE_PATH . '/core/FrontController.php');

It would seem that directory structure you're trying to use is wrong, perhaps you should revise that and try to keep all files under the localhost directory.

Category:php Views:0 Time:2012-02-11
Tags: php piwik

Related post

  • Paypal Direct Payment API 2011-04-25

    Is there any up to date documentation out there on how to use the Paypal direct payment API? --------------Solutions------------- I found a working demo code for Paypal direct payment API : http://www.mmtutorialvault.com/paypal-pro-integration-in-php

  • Changing bit format on a Windows mobile device through direct draw APIs 2012-02-02

    I am working on a Windows Mobile 6.5 device and want to copy an image from one application (drawn using GDI) to another application (using direct draw). Currently I am doing bit conversion for this since the direct draw supports only 16-bit whereas t

  • How to send "Cache-Control: no-cache" header in Piwik API responses 2011-08-14

    I have a Piwik install sitting behind a varnish-caching server. My problem is varnish is by default caching responses to my API calls. Unfortunately, I don't have direct access to the varnish server, so I need to send the "Cache-Control: no-cache" he

  • Paypal Direct Payment API using Paypal account 2011-02-14

    is it possible to make a payment with user's paypal balance using Direct Payment? I know that Direct Payment offers recurring payments but I'd like to use it not only for credit cards but for paypal account balance too. Is it possible or not at all?

  • Has anyone integrated the Datacash Direct Debit api? Or Direct Debits in general? Need advice (UK) 2011-04-21

    Sorry if this is a bit off topic but I've run out of places to look! There isn't much info out there on the Datacash api so if anyones worked with it on direct debits in the UK maybe you can help. I believe that this is the only way I can do this and

  • Piwik API how to get daily visits for 7 days 2011-08-26

    I'm trying to get daily visits from my instance of piwik for every day in the week. Currently this query is returning the sum of all my visits for the entire week. Is there any way to separate this out into days? http://piwikexample.com/?module=API

  • Is there any free directions REST API compatible with OpenStreetMap? 2011-09-08

    I failed to find any official docs if OpenStreetMap provide any API for directions. Maybe there is some other free service for this task? --------------Solutions------------- There is nothing provided directly by the OpenStreetMap project, but there

  • Difference between direct GRAPH API and PHP SDK result in page feed comments 2011-04-15

    I am trying to get the feed of a certain page through Facebook's GRAPH API, using their PHP SDK. I have found that by calling this in my browser: https://graph.facebook.com/XXXXX/feed I'm getting the fresh feed, and finding a particular post I only s

  • Direct Entitlement API - passing error code 2014-10-20

    Hi, I'm trying to implement login API in our DPS application. I can see that there is a possibility to provide an errorCode in the SignInWithCredentials action. Error Results: HTTP 401 Unauthorized Body: <result httpResponseCode=”401” errorCode=””

  • for windows programming in use direct windows api i should use MessageLoop? 2011-01-10

    in windows programming i should use MessageLoop? i see any program have messageLoop but in this code the autor dont use messageloop code snippet : int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { I

  • Saving Dragable Directions Google Directions API v3 2011-02-15

    I'm making an app with the Directions API to create biking directions. The user needs to be able to start from a custom point, add custom stopping points along the route, and actually drag the directions. Once they're done, I need to save the new rou

  • Access direct messages via Twitter API 2012-03-08

    I am trying to access the Twitter direct messaging API. I have set up an app and set the permissions to Read, write, and direct messages: However, when I test the application and see the authorisation screen, direct messaging is not included in the p

  • What online brokers offer APIs? 2008-09-12

    So I'm getting really sick of E*TRADE and, being a developer, would love to find an online broker that offers an API. It would be great to be able to write my own trading tools, and maybe even modify existing ones. Based on my research so far, I've o

  • What Web Analytics Sites/Software Have a Good API Besides Google Analytics 2009-10-10

    I cannot use Google analytics because of their limitations on the API. They will not allow me to query more then 10,000 entries in one day. Since I have more then 10,000 pages Google Analytics will not work for me unless there is a way around that 10

  • How to implement RESTful API on an App Engine server with webapp ( +Facebook authentication )? 2009-12-28

    so my idea is pretty simple. But I don't know where to start. develop a simple RESTful API on my app engine server using the simple webapp framework. there will be two kinds of clients: 1. Normal pc users access the facebook application, and this wil

  • Uploading large video via Youtube API causing Out of Memory 2010-01-24

    I'm using PHP to send videos via Direct Upload to Youtube. It works fine for smaller sized videos but when trying to send a 390 MB video, I get the following error: PHP Fatal error: Out of memory (allocated 3932160) (tried to allocate 390201902 bytes

  • Can we play only audio using youtube api for iPhone 2010-02-22

    In my project i have to use youtube api and play only audio of the video. We must not show the youtube player. Is it possible to play only audio without showing video using youtube api? --------------Solutions------------- Extraction may be the incor

  • Diffence between FQL query and Graph API object access 2010-05-05

    What's the difference between accessing user data with the Facebook Graph API (http://graph.facebook.com/btaylor) and using the Graph API to make a FQL query of the same user (https://api.facebook.com/method/fql.query?query=QUERY). Also, does anyone

  • Which Facebook APIs can be used to programatically post a message? 2010-06-28

    I have an application that allows a user to post messages. I'd like to give an option to users to propagate the same posts on their Facebook wall / status. Which Facebook APIs can I leverage, including the ones that are need to authenticate the user?

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.169 (s). 11 q(s)