exinfinite/piwik-linker

api wraper for piwik

1.0.1 2020-11-06 03:44 UTC

This package is auto-updated.

Last update: 2024-11-06 12:50:19 UTC


README

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"
        }
    ]
}