src/Webtrees/Module/WelcomeBlock/PiwikController.php
private function getNumberOfVisitsPiwik($block_id, $period='year'){
    
        $piwik_url = $this->module->getBlockSetting($block_id, 'piwik_url');
        $piwik_siteid = $this->module->getBlockSetting($block_id, 'piwik_siteid');
        $piwik_token = $this->module->getBlockSetting($block_id, 'piwik_token');
    
        if($piwik_url && strlen($piwik_url) > 0 &&
            $piwik_siteid  && strlen($piwik_siteid) > 0 &&
            $piwik_token && strlen($piwik_token)            
            ) 
        {        
            // calling Piwik REST API
            $url = $piwik_url;
            $url .= '?module=API&method=VisitsSummary.getVisits';
            $url .= '&idSite='.$piwik_siteid.'&period='.$period.'&date=today';
            $url .= '&format=PHP';
            $url .= '&token_auth='.$piwik_token;
        
            if($fetched = File::fetchUrl($url)) {
                $content = @unserialize($fetched);
                if(is_numeric($content)) return $content;
            }
        }
    
        return null;
    }
private function getNumberOfVisitsPiwik($block_id, $period='year'){
    
        $piwik_url = $this->module->getBlockSetting($block_id, 'piwik_url');
        $piwik_siteid = $this->module->getBlockSetting($block_id, 'piwik_siteid');
        $piwik_token = $this->module->getBlockSetting($block_id, 'piwik_token');
    
        if($piwik_url && strlen($piwik_url) > 0 &&
            $piwik_siteid  && strlen($piwik_siteid) > 0 &&
            $piwik_token && strlen($piwik_token)            
            ) 
        {        
            // calling Piwik REST API
            $url = $piwik_url;
            $url .= '?module=API&method=VisitsSummary.getVisits';
            $url .= '&idSite='.$piwik_siteid.'&period='.$period.'&date=today';
            $url .= '&format=PHP';
            $url .= '&token_auth='.$piwik_token;
        
            if($fetched = File::fetchUrl($url)) {
                $content = @unserialize($fetched);
                if(is_numeric($content)) return $content;
            }
        }
    
        return null;
    }
private function getNumberOfVisitsPiwik ( $ block_id , $ period = 'year' ) { $ piwik_url = $ this -> module -> getBlockSetting ( $ block_id , 'piwik_url' ) ; $ piwik_siteid = $ this -> module -> getBlockSetting ( $ block_id , 'piwik_siteid' ) ; $ piwik_token = $ this -> module -> getBlockSetting ( $ block_id , 'piwik_token' ) ; if ( $ piwik_url && strlen ( $ piwik_url ) > 0 && $ piwik_siteid && strlen ( $ piwik_siteid ) > 0 && $ piwik_token && strlen ( $ piwik_token ) ) { // calling Piwik REST API $ url = $ piwik_url ; $ url .= '?module=API&method=VisitsSummary.getVisits' ; $ url .= '&idSite=' . $ piwik_siteid . '&period=' . $ period . '&date=today' ; $ url .= '&format=PHP' ; $ url .= '&token_auth=' . $ piwik_token ; if ( $ fetched = File :: fetchUrl ( $ url ) ) { $ content = @ unserialize ( $ fetched ) ; if ( is_numeric ( $ content ) ) return $ content ; } } return null ; }
Retrieve the number of visitors from Piwik, for a given period.

@param string $block_id
@param string $period
@param (null|int) Number of visits
Retrieve the number of visitors from Piwik for a given period .