Skip to content

exinfinite/piwik-linker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

piwik-linker

Packagist PHP Version Support GitHub release (latest SemVer) Packagist Version Packagist Downloads GitHub

安裝

composer require exinfinite/piwik-linker

建立設定

$config = new \Exinfinite\PiwikLinker\Config('piwik_url', 'site_id', 'auth_token');

引用模組

$live = new \Exinfinite\PiwikLinker\Modules\Live($config);

串接Piwik API

$json = $live->getLastVisitsDetails('day', 'today');//回傳json

自訂輸出欄位

$formater = function ($visitor) {
    return [
        'title' => $visitor['exitPageTitle'],
        'url' => $visitor['exitPageUrl']
    ];
};
echo \Exinfinite\PiwikLinker\Parser\Parser::jsonCollectionTransform($json, $formater);

輸出結果

{
    "data": [
        {
            "title": "page title",
            "url": "page url"
        }
    ]
}