Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling the API in PHP breaks timezone, or just does not work #8445

Closed
LeCoyote opened this issue Jul 28, 2015 · 2 comments
Closed

Calling the API in PHP breaks timezone, or just does not work #8445

LeCoyote opened this issue Jul 28, 2015 · 2 comments
Labels
worksforme The issue cannot be reproduced and things work as intended.

Comments

@LeCoyote
Copy link

Ref: #3921

It seems that calling the API in PHP is still partly broken.

Using the code provided in http://developer.piwik.org/guides/querying-the-reporting-api results in a piece of code that changes the default timezone to UTC. In other words, using Piwik as documented will force the calling code to use UTC as a default timezone. This behaviour is intrusive and not documented. I'll see if I can edit the wiki later.

Moreover, the code sample mentions:
// 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"
Clearly, this is not sufficient. Doing so will result in the following:
PHP Fatal error: Class 'Piwik\\Application\\Environment' not found in <path>
This part of the documentation cannot be edited via the wiki.

As a result, there still seems to be no clean way of using the API directly in PHP.

@LeCoyote
Copy link
Author

Apparently, the "correct" way to include the API would be:

require_once PIWIK_INCLUDE_PATH . "/libs/upgradephp/upgrade.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";

// Additional includes missing from documentation
require_once PIWIK_INCLUDE_PATH . '/vendor/autoload.php';

This is for 2.14.2 ; 2.14.1 still appears to have the old core/Loader.php (which for some reason does not get deleted when upgrading from 1.x, but that's another issue and frankly, I'm too annoyed to create another one for now)

mattab added a commit that referenced this issue Sep 18, 2015
@mattab
Copy link
Member

mattab commented Sep 18, 2015

Thanks for feedback @LeCoyote. I removed the outdated comment in 6d86b4d.

When I try the code in developer doc, it works for me. if you still have a problem please create a new issue and put your whole test code we can use to reproduce the issue

@mattab mattab closed this as completed Sep 18, 2015
@mattab mattab added the worksforme The issue cannot be reproduced and things work as intended. label Sep 18, 2015
mattab added a commit that referenced this issue Oct 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
worksforme The issue cannot be reproduced and things work as intended.
Projects
None yet
Development

No branches or pull requests

2 participants