Json format in Piwik_API_Request prompts download?


#1

Hi,

Would appreciate help on this one as I’m facing troubles with json format, using PHP’s Piwik_API_Request…

using

$request = new Piwik_API_Request(“
method=UserSettings.getResolution
&idSite=1
&date=today
&period=week
&format=json
&filter_limit=3
&token_auth=$token” ) ;

the results are returned in a file and my IE8 is prompted to download the file
which is not what I want…

What I want is to achieve this:
$result=$request->process();
$obj = utf8_decode($result);

echo $obj[0]->{‘label’};

instead, it is currently echoing the results in a file that IE8 is prompting me to download…

I would simply like to display the results only and not prompt my users to download the file…
Is this a known issue for json format, or is it only me? How can I solve this? Thanks!!

(Current version using : 1.2.5-rc6 / IE8)


(Matthieu Aubry) #2

I recommend you use the format=php to do this?


#3

Thanks for your reply.

I have changed to using format=php now and using unserialize to get the array of data…

However, does that mean that I cannot use json format ? Is the format=json supposed to prompt an IE download window?
It seemed like the right way to do it since I saw that I could do stuff like $object = json_decode($result) and then $object->{‘nb_actions’} to retrieve the number of actions… but the prompting by IE to download the file is simply weird.


(Matthieu Aubry) #4

I agree it shouldn’t be this way, created a bug report: Allow to disable all header() calls when Piwik API is used via internal method · Issue #2294 · matomo-org/matomo · GitHub