I've got a warning message if I use the API from a different domain on the same server.
Warning: Invalid argument supplied for foreach() in /users/XXXXXXX/data/websites/myDomain/plugins/LanguagesManager/API.php on line 34
The Piwik installation is located on '/users/XXXXXXX/data/websites/myDomain' on the server and I call the Piwik API from a different domain (roor: '/users/XXXXXXX/data/websites/mySecondDomain') on the same server with the Internal PHP calling example in the wiki.
After the warning messages the result of the API is displayed correctly.
I think the line 32 in /plugins/LanguagesManager/API.php
$languages = glob( "lang/*");
points to a wrong folder if the API-call is not executed in the piwik Folder.
Seems not to work.
$olddir: '/users/XXXXXXX/data/websites/MyDomain' $_SERVER['SCRIPT_FILENAME']: '/users/XXXXXXX/data/websites/myDomain/testing.php'
In testing.php piwik is executed by including (see the example in the wiki):
define('PIWIK_INCLUDE_PATH', '/users/XXXXXXX/data/websites/MyPiwikDomain'); define('ENABLE_DISPATCH', false); require_once PIWIK_INCLUDE_PATH . "/index.php"; require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
Maybe something like this:
$olddir = getcwd(); if (defined ('PIWIK_INCLUDE_PATH')) chdir(PIWIK_INCLUDE_PATH); $languages = glob( "lang/*"); chdir( $olddir );
Here's a simpler patch.
vipsoft and Jako, did you test the patch with the use case? Please confirm before commit. Thanks
I didn't hear back from Jako, but I tested the patch (in the attachment).
thanks for patch Anthon. Fixed in (just slight style changes)
Sorry for answering late. The patch works for me. Thanks!