PHP code example of webcrea / yandex-metrika-sdk
1. Go to this page and download the library: Download webcrea/yandex-metrika-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webcrea / yandex-metrika-sdk example snippets
$counterId = '';
$token = '';
// CDP API
$cdp = new \WebCrea\YandexMetrikaSdk\Api\CdpApi($token);
// Management API
$management = new \WebCrea\YandexMetrikaSdk\Api\ManagementApi($token);
$counterId = '00000000';
$token = '00000000000000000000';
$cdp = new \WebCrea\YandexMetrikaSdk\Api\CdpApi($token);
// Сопоставление статусов заказов
$map['order_statuses'] = [
[
'id' => 'NO',
'humanized' => 'Не оплачен',
'type' => 'IN_PROGRESS',
],
[
'id' => 'N',
'humanized' => 'Новый заказ',
'type' => 'IN_PROGRESS',
],
];
$result = $cdp->mapOrderStatuses($counterId, $map);
// Загрузка заказов (JSON)
$orders['orders'] = [
[
"id" => "32152",
"client_uniq_id" => "sertw345fgdsg",
"client_type" => "CONTACT",
"create_date_time" => "2020-04-14 13:17:00",
"update_date_time" => "2020-04-17 16:12:21",
"finish_date_time" => "2020-04-17 11:59:00",
"revenue" => 2000,
"order_status" => "N",
"cost" => 100500,
"products" => ["Товар А" => 173, "Товар Б" => 146],
],
];
$result = $cdp->uploadOrdersJson($counterId, $orders, ['merge_mode' => 'SAVE']);
// Информация о последних загрузках
$result = $cdp->getLastUploadings($counterId);
public function mapOrderStatuses(int $counterId, array $content): array
public function uploadContactsJson(int $counterId, array $content, array $requestParams): array
public function uploadOrdersJson(int $counterId, array $content, array $requestParams): array
public function createAttributes(int $counterId, array $content, array $requestParams = []): array
public function createProducts(int $counterId, array $content): array
public function getAttributes(int $counterId, array $requestParams = []): array
public function getPredefinedTypes(int $counterId): array
public function getTypes(int $counterId): array
public function getLastUploadings(int $counterId, array $requestParams = []): array