Browse Source

fixed API call that was borked by matomo upgrade

windhamdavid 3 years ago
parent
commit
699ff382a9
2 changed files with 38 additions and 38 deletions
  1. 30 30
      inc/analytics.php
  2. 8 8
      page-analytics.php

+ 30 - 30
inc/analytics.php

@@ -5,43 +5,43 @@ function dw_wik_places() {
 	$url = "https://davidawindham.com/wik/";
 	$url .= "?module=API&method=UserCountry.getCity";
 	$url .= "&idSite=1&period=month&date=yesterday";
-	$url .= "&format=PHP&filter_limit=20";
-	$url .= "&token_auth=d97e3e8f34071515ad1f6e345f6035af";
+	$url .= "&format=JSON&filter_limit=20";
+	$url .= "&token_auth=3910b0da85f448ae35d4b75b4e6912bb";
 
 	$fetched = file_get_contents($url);
-	$content = unserialize($fetched);
+	$content = json_decode($fetched,true);
 
 	if (!$content) {
 	    print("Error, content fetched = " . $fetched);
 	}
 
 	foreach ($content as $row) {
-	    $location = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
-	    $hits = $row['nb_visits'];
+	  $location = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
+	  $hits = $row['nb_visits'];
 		$logo = $row['logo'];
 		$length = $row['sum_visit_length'];
-	    print("<li class='list-group-item small'><img src='https://davidawindham.com/wik/$logo'/> &nbsp; $location  <span class='badge'> $hits </span></li>");
+	  print("<li class='list-group-item small'><img src='https://davidawindham.com/wik/$logo' style='width:30px;'/> &nbsp; $location  <span class='badge'> $hits </span></li>");
 	}
 }
 
 
 function dw_wik_url() {
-	
+
 	$url = "https://davidawindham.com/wik/";
 	$url .= "?module=API&method=Actions.getPageUrls";
 	$url .= "&idSite=1&period=month&date=yesterday";
-	$url .= "&format=PHP&filter_limit=20";
-	$url .= "&token_auth=d97e3e8f34071515ad1f6e345f6035af";
+	$url .= "&format=JSON&filter_limit=20";
+	$url .= "&token_auth=3910b0da85f448ae35d4b75b4e6912bb";
 
 	$fetched = file_get_contents($url);
-	$content = unserialize($fetched);
+	$content = json_decode($fetched,true);
 
 	if (!$content) {
 	    print("Error, content fetched = " . $fetched);
 	}
 
 	foreach ($content as $row) {
-	    $urls = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
+	  $urls = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
 		$label = $row['label'];
 		$hits = $row['nb_hits'];
 		$time = $row['avg_time_on_page'];
@@ -51,76 +51,76 @@ function dw_wik_url() {
 }
 
 function dw_wik_users() {
-	
+
 	$url = "https://davidawindham.com/wik/";
 	$url .= "?module=API&method=DevicesDetection.getOsFamilies";
 	$url .= "&idSite=1&period=month&date=yesterday";
-	$url .= "&format=PHP&filter_limit=10";
-	$url .= "&token_auth=d97e3e8f34071515ad1f6e345f6035af";
+	$url .= "&format=JSON&filter_limit=10";
+	$url .= "&token_auth=3910b0da85f448ae35d4b75b4e6912bb";
 
 	$fetched = file_get_contents($url);
-	$content = unserialize($fetched);
+	$content = json_decode($fetched,true);
 
 	if (!$content) {
 	    print("Error, content fetched = " . $fetched);
 	}
 
 	foreach ($content as $row) {
-	    $urls = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
+	  $urls = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
 		$label = $row['label'];
 		$hits = $row['nb_visits'];
-	    print("<li class='list-group-item small'> $label <span class='badge'> $hits </span></li>");
+	  print("<li class='list-group-item small'> $label <span class='badge'> $hits </span></li>");
 	}
 
 }
 
 
 function dw_wik_keys() {
-	
+
 	$url = "https://davidawindham.com/wik/";
 	$url .= "?module=API&method=Referrers.getReferrerType";
 	$url .= "&idSite=1&period=month&date=yesterday";
-	$url .= "&format=PHP&filter_limit=20";
-	$url .= "&token_auth=d97e3e8f34071515ad1f6e345f6035af";
+	$url .= "&format=JSON&filter_limit=20";
+	$url .= "&token_auth=3910b0da85f448ae35d4b75b4e6912bb";
 
 	$fetched = file_get_contents($url);
-	$content = unserialize($fetched);
+	$content = json_decode($fetched,true);
 
 	if (!$content) {
 	    print("Error, content fetched = " . $fetched);
 	}
 
 	foreach ($content as $row) {
-	    $urls = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
+	  $urls = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
 		$label = $row['label'];
 		$hits = $row['nb_visits'];
-	    print("<li class='list-group-item small'> $label <span class='badge'> $hits </span></li>");
+	  print("<li class='list-group-item small'> $label <span class='badge'> $hits </span></li>");
 	}
 
 }
 
 function dw_wik_refs() {
-	
+
 	$url = "https://davidawindham.com/wik/";
 	$url .= "?module=API&method=Referrers.getAll";
 	$url .= "&idSite=1&period=month&date=yesterday";
-	$url .= "&format=PHP&filter_limit=20";
-	$url .= "&token_auth=d97e3e8f34071515ad1f6e345f6035af";
+	$url .= "&format=JSON&filter_limit=20";
+	$url .= "&token_auth=3910b0da85f448ae35d4b75b4e6912bb";
 
 	$fetched = file_get_contents($url);
-	$content = unserialize($fetched);
+	$content = json_decode($fetched,true);
 
 	if (!$content) {
 	    print("Error, content fetched = " . $fetched);
 	}
 
 	foreach ($content as $row) {
-	    $urls = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
+	  $urls = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
 		$label = $row['label'];
 		$hits = $row['nb_visits'];
-	    print("<li class='list-group-item small'> $label <span class='badge'> $hits </span></li>");
+	  print("<li class='list-group-item small'> $label <span class='badge'> $hits </span></li>");
 	}
 
 }
 
-?>
+?>

+ 8 - 8
page-analytics.php

@@ -1,6 +1,6 @@
 <?php get_header(); ?>
 	<div class="container-full" style="margin:80px 0 -100px">
-		<iframe id="map" width="100%" height="600px" scrolling="yes" frameborder="0"  style="background:#fff" src="https://davidawindham.com/wik/index.php?module=Widgetize&action=iframe&widget=1&moduleToWidgetize=UserCountryMap&actionToWidgetize=realtimeMap&idSite=1&period=day&date=today&disableLink=1&widget=1&token_auth=d97e3e8f34071515ad1f6e345f6035af" /></iframe>
+		<iframe id="map" width="100%" height="600px" scrolling="yes" frameborder="0"  style="background:#fff" src="https://davidawindham.com/wik/index.php?module=Widgetize&action=iframe&widget=1&moduleToWidgetize=UserCountryMap&actionToWidgetize=realtimeMap&idSite=1&period=day&date=today&disableLink=1&widget=1&token_auth=3910b0da85f448ae35d4b75b4e6912bb"></iframe>
 	</div>
 	<div class="container" role="main">
 		<article  id="content" class="single" >
@@ -12,8 +12,8 @@
 			</div>
 			<div class="row">
 				<div class="col-sm-6">
-					<h4>Rencent Visitors</h4>
-					<ul class="list-group">	
+					<h4>Recent Visitors</h4>
+					<ul class="list-group">
 						<?php echo dw_wik_places()?>
 					</ul>
 				</div>
@@ -28,23 +28,23 @@
 			<div class="row">
 				<div class="col-sm-6">
 					<h4>Operating System</h4>
-					<ul class="list-group">	
+					<ul class="list-group">
 						<?php echo dw_wik_users()?>
 					</ul>
 				</div>
 				<div class="col-sm-6">
 					<h4>Referrals</h4>
-					<ul class="list-group">	
+					<ul class="list-group">
 						<?php echo dw_wik_keys()?>
 					</ul>
 					<h4>Referral Sources</h4>
-					<ul class="list-group">	
+					<ul class="list-group">
 						<?php echo dw_wik_refs()?>
 					</ul>
 				</div>
 			</div>
-			
+
 		</article>
 	</div>
 
-<?php get_footer(); ?>
+<?php get_footer(); ?>