]> _ Git - cubist_matomo.git/commitdiff
wip #4978 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Dec 2021 19:16:59 +0000 (20:16 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Dec 2021 19:16:59 +0000 (20:16 +0100)
.idea/deployment.xml
src/Reporting.php

index 586b23fc77e09e949a83298421746171561e74b3..3d028c617c4fbb9069d89630b81d2ca0d206dfa3 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
-  <component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
+  <component name="PublishConfigData" autoUpload="Always" serverName="workshop.fluidbook.com" remoteFilesAllowedToDisappearOnAutoupload="false" autoUploadExternalChanges="true">
     <serverData>
       <paths name="apps.fluidbook.com">
         <serverdata>
       <paths name="workshop.fluidbook.com">
         <serverdata>
           <mappings>
-            <mapping local="$PROJECT_DIR$" web="/" />
+            <mapping deploy="/vendor/cubist/matomo" local="$PROJECT_DIR$" web="/" />
           </mappings>
+          <excludedPaths>
+            <excludedPath local="true" path="$PROJECT_DIR$/vendor" />
+          </excludedPaths>
         </serverdata>
       </paths>
       <paths name="www.adangelis.com">
         </serverdata>
       </paths>
     </serverData>
+    <option name="myAutoUpload" value="ALWAYS" />
   </component>
 </project>
\ No newline at end of file
index 295032377c680f87058be7033e866989306905b5..2cd33ea593cccd1d51ff2d0d30300a004f2a5ad8 100644 (file)
@@ -17,21 +17,35 @@ class Reporting
      */
     protected $client;
 
+    /**
+     * @var null|array
+     */
+    protected $_allSites = null;
+
     public function __construct($baseURL, $token)
     {
         $this->token = $token;
         $this->client = new Client(['base_uri' => $baseURL]);
     }
 
-    protected function getAllSites()
+    /**
+     * @return array
+     */
+    public function getAllSites()
     {
-        $allSites = $this->_apicall('SitesManager.getAllSites');
-        print_r($allSites);
+        if (null === $this->_allSites) {
+            $a = $this->_apicall('SitesManager.getAllSites');
+            $this->_allSites = [];
+            foreach ($a as $item) {
+                $this->_allSites[$item['idsite']] = $item;
+            }
+        }
+        return $this->_allSites;
     }
 
     public function getSiteIdByURL($url)
     {
-
+        return $this->_apicall('SitesManager.getSitesIdFromSiteUrl',['url'=>$url]);
     }
 
 
@@ -40,12 +54,12 @@ class Reporting
         $default = [
             'method' => $method,
             'module' => 'API',
-            'token' => $this->token,
+            'token_auth' => $this->token,
             'format' => 'JSON'
         ];
         $defaultOptions = ['query' => array_merge($default, $params)];
 
-        $response = $this->client->get(null, array_merge($defaultOptions, $options));
-        return json_decode($response->getBody()->getContents());
+        $response = $this->client->get('/', array_merge($defaultOptions, $options));
+        return json_decode($response->getBody()->getContents(), true);
     }
 }
\ No newline at end of file