Skip to content

Commit 11d754e

Browse files
authored
Merge pull request #28 from ehmeister/changeapiformat
Alter API request format to JSON
2 parents 8ba8bec + 7e6b09e commit 11d754e

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/matomo.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ public function apiWidget($widget, $method, $period, $date, $limit, $lang) {
5454
$url = $this->url;
5555
$url .= "?module=API&method=" . $method;
5656
$url .= "&idSite=". $this->id ."&period=". $period ."&date=" . $date;
57-
$url .= "&format=PHP&language=". $lang;
57+
$url .= "&format=JSON&language=". $lang;
5858
$url .= $limit ? "&filter_limit=" . $limit : '';
5959
$url .= "&token_auth=". $this->token;
6060

6161
$fetched = file_get_contents($url);
62-
$content = unserialize($fetched);
62+
$content = json_decode($fetched,true);
6363

6464
return $content;
6565
}
@@ -70,7 +70,7 @@ public function apiBulkWidgets($widgets, $period, $date, $limit, $lang) {
7070
$url = $this->url;
7171

7272
$url .= "?module=API&method=API.getBulkRequest";
73-
$url .= "&token_auth=". $this->token ."&format=PHP";
73+
$url .= "&token_auth=". $this->token ."&format=JSON";
7474

7575
$i = 0;
7676
foreach($widgets as $widget) {
@@ -80,7 +80,7 @@ public function apiBulkWidgets($widgets, $period, $date, $limit, $lang) {
8080
}
8181

8282
$fetched = file_get_contents($url);
83-
$content = unserialize($fetched);
83+
$content = json_decode($fetched,true);
8484

8585
return $content;
8686
}
@@ -89,10 +89,10 @@ public function apiChart($method, $period, $date) {
8989
$url = $this->url;
9090
$url .= "?module=API&method=". $method;
9191
$url .= "&idSite=". $this->id ."&period=". $period ."&date=" . $date;
92-
$url .= "&format=PHP&token_auth=". $this->token;
92+
$url .= "&format=JSON&token_auth=". $this->token;
9393

9494
$fetched = file_get_contents($url);
95-
$content = unserialize($fetched);
95+
$content = json_decode($fetched,true);
9696

9797
return $content;
9898
}
@@ -101,10 +101,10 @@ public function apiOverview($method, $period, $date) {
101101
$url = $this->url;
102102
$url .= "?module=API&method=". $method;
103103
$url .= "&idSite=". $this->id ."&period=". $period ."&date=" . $date;
104-
$url .= "&format=PHP&token_auth=". $this->token;
104+
$url .= "&format=JSON&token_auth=". $this->token;
105105

106106
$fetched = file_get_contents($url);
107-
$content = unserialize($fetched);
107+
$content = json_decode($fetched,true);
108108

109109
return $content;
110110
}
@@ -115,10 +115,10 @@ public function apiRealtime() {
115115

116116
$url .= "?module=API&method=" . $method;
117117
$url .= "&idSite=". $this->id ."&lastMinutes=3";
118-
$url .= "&format=PHP&token_auth=". $this->token;
118+
$url .= "&format=JSON&token_auth=". $this->token;
119119

120120
$fetched = file_get_contents($url);
121-
$content = unserialize($fetched);
121+
$content = json_decode($fetched,true);
122122

123123
return $content;
124124
}
@@ -127,7 +127,7 @@ public function apiBulkSummary() {
127127
$url = $this->url;
128128

129129
$url .= "?module=API&method=API.getBulkRequest";
130-
$url .= "&token_auth=". $this->token ."&format=PHP";
130+
$url .= "&token_auth=". $this->token ."&format=JSON";
131131

132132
$url .= "&urls[0]=";
133133
$url .= urlencode("method=VisitsSummary.getVisits&idSite=". $this->id ."&period=day&date=today");
@@ -142,7 +142,7 @@ public function apiBulkSummary() {
142142
$url .= urlencode("method=VisitsSummary.getVisits&idSite=". $this->id ."&period=year&date=today");
143143

144144
$fetched = file_get_contents($url);
145-
$content = unserialize($fetched);
145+
$content = json_decode($fetched,true);
146146

147147
return $content;
148148
}
@@ -151,11 +151,11 @@ public function apiPageMetrics($period, $uri, $lang) {
151151
$url = $this->url;
152152
$url .= "?module=API&method=Actions.getPageUrls";
153153
$url .= "&idSite=". $this->id ."&period=". $period ."&date=today";
154-
$url .= "&format=PHP&token_auth=". $this->token;
154+
$url .= "&format=JSON&token_auth=". $this->token;
155155
$url .= $lang['multilang'] ? '&expanded=1' : '';
156156

157157
$fetched = file_get_contents($url);
158-
$content = unserialize($fetched);
158+
$content = json_decode($fetched,true);
159159
$content = $this->filterPageMetrics($content, $uri, $lang);
160160
return $content;
161161
}

src/components/widgets/summary.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ export default {
6363
this.$api
6464
.get('matomo-panel/get-bulk-summary')
6565
.then(response => {
66-
this.results.day = response[0]
66+
this.results.day = response[0].value
6767
this.results.week = this.getLast7Days(response[1])
68-
this.results.month = response[2]
69-
this.results.year = response[3]
68+
this.results.month = response[2].value
69+
this.results.year = response[3].value
7070
7171
this.loading = false
7272
this.status = response.status

0 commit comments

Comments
 (0)