-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
a.pushkarev
committed
May 30, 2022
1 parent
761505d
commit 2e44053
Showing
4 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
3. [Ответ](#Ответ) | ||
+ [Чистые данные](#Чистые-данные) | ||
+ [Отформатированные данные](#Отформатированные-данные) | ||
+ [Свой формат данных](#Свой-формат-данных) | ||
4. [Автор](#Автор) | ||
5. [Лицензия](#Лицензия) | ||
|
||
|
@@ -54,6 +55,7 @@ $metrika = new YaMetrika($client); | |
+ [Данные о посещаемости](https://github.com/axp-dev/ya-metrika/blob/master/example/visitors.php) | ||
+ [Логирование запросов](https://github.com/axp-dev/ya-metrika/blob/master/example/logger.php) | ||
+ [Использование Proxy](https://github.com/axp-dev/ya-metrika/blob/master/example/proxy.php) | ||
+ [Использование custom format](https://github.com/axp-dev/ya-metrika/blob/master/example/format.php) | ||
|
||
## Использование | ||
### Данные по посещаемости | ||
|
@@ -242,6 +244,12 @@ public function rawData(): array | |
public function formatData(): array | ||
``` | ||
|
||
### Свой формат данных | ||
Возвращает отформатированные данные. Будут переименованы поля, удалены ненужные префиксы. | ||
```php | ||
public function customFormat(callable $callback): array | ||
``` | ||
|
||
## Автор | ||
[Alexander Pushkarev](https://github.com/axp-dev), e-mail: [[email protected]](mailto:[email protected]) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
use AXP\YaMetrika\Client; | ||
use AXP\YaMetrika\YaMetrika; | ||
|
||
$token = getenv('TOKEN'); | ||
$counterId = getenv('COUNTER_ID'); | ||
|
||
$client = new Client($token, $counterId); | ||
$metrika = new YaMetrika($client); | ||
|
||
$visitors = $metrika->getVisitors(); | ||
$totals = $visitors->customFormat(function ($data) { | ||
return $data['totals']; | ||
}); | ||
|
||
print_r($totals); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters