exinfinite / piwik-linker
api wraper for piwik
1.0.1
2020-11-06 03:44 UTC
Requires
- php: ^5.6
- exinfinite/helpers: ^1.3
- spatie/fractalistic: ^2.7
README
安裝
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" } ] }