composer require exinfinite/piwik-linker
$config = new \Exinfinite\PiwikLinker\Config('piwik_url', 'site_id', 'auth_token');
$live = new \Exinfinite\PiwikLinker\Modules\Live($config);
$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"
}
]
}