pfrenssen/matomo-reporting-api
Composer 安装命令:
composer require pfrenssen/matomo-reporting-api
包简介
PHP client library to query the Matomo Reporting API.
README 文档
README
(former Piwik Reporting API)
This library allows to retrieve data from the Matomo open source web analytics platform using the Matomo Reporting API using PHP.
Usage
<?php
use Matomo\ReportingApi\QueryFactory;
require getcwd() . '/vendor/autoload.php';
// The URL of the Matomo server. *Always use HTTPS!*
$matomo_url = 'https://my.matomo.server';
// The user authentication token. You can get it in the web interface of the
// Matomo server at Administration > Platform > API.
$token = 'e0357ffdf830ca8be8af4151b564b53d';
// Instantiate the query factory. This class helps to quickly generate
// different query objects with reusable default parameters.
$query_factory = QueryFactory::create($matomo_url);
// Set some default parameters such as the site ID and user authentication
// token.
$query_factory
->set('idSite', 1)
->set('token_auth', $token);
// Example: retrieve the version of the Matomo server.
$query = $query_factory->getQuery('API.getMatomoVersion');
$response = $query->execute()->getResponse();
$matomo_version = $response->value;
echo "Server is running Matomo $matomo_version.\n\n";
// Example: retrieve browser usage statistics for the past week.
$response = $query_factory->getQuery('DevicesDetection.getBrowsers')
->setParameter('date', 'today')
->setParameter('period', 'week')
->execute()
->getResponse();
foreach ($response as $browser) {
echo "Browser: {$browser->label}\n";
echo "Total visits: {$browser->nb_visits}\n";
echo "Bounce count: {$browser->bounce_count}\n";
echo "Daily unique visitors: {$browser->sum_daily_nb_uniq_visitors}\n\n";
}
For the full list of available methods, see the Matomo API reference.
Security
The Matomo Reporting API uses a user authentication token to access the API. The API is very powerful and allows to view, edit and delete most data, even add and remove users. This means that the user authentication token should be kept as secret as your username and password.
Since the token is sent over the network it is crucial that all network traffic to the Matomo API is encrypted. You can use an unencrypted HTTP URL during testing, but for a production server it is highly recommended to use HTTPS or it will be possible for an attacker to steal your credentials and lock you out of your Matomo server.
pfrenssen/matomo-reporting-api 适用场景与选型建议
pfrenssen/matomo-reporting-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 122.88k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2018 年 08 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 pfrenssen/matomo-reporting-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pfrenssen/matomo-reporting-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 122.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2018-08-15