konkord-llc / konkord
Yandex Metrika API PHP
1.0
2021-07-22 18:14 UTC
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2024-09-28 08:43:29 UTC
README
Yandex Metrika API (PHP) 纯PHP库
安装
- 在文件
config.php
中写入访问令牌和计数器编号 - 将项目连接到
include_once(DIR."/YandexMetrica.php");
- 创建对象
$getMetrica->new konkord\YandexMetrika();
- 传入API URL
$getMetrica->url = "https://api-metrika.yandex.net/stat/v1/data/bytime?";
- 传入必需参数
$getMetrica->parametrs = [
'date1' => 'today', // $startDate < $endDate. 开始日期
'date2' => 'today', // 结束日期
'metrics' => 'ym:s:visits,ym:s:pageviews,ym:s:users,ym:s:bounceRate,ym:s:pageDepth,ym:s:avgVisitDurationSeconds' // 指标
]; - 调用
$result=$getMetrica->GetFromMetrica();
- 输出结果
var_dump($result);
/* 如有意愿感谢,请通过以下储蓄卡:2202 2018 6769 5815 */