dicr/yii2-topvisor

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

TopVisor API for Yii2

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Type:yii2-extension

3.0.0 2021-05-11 13:21 UTC

This package is auto-updated.

Last update: 2021-10-11 09:17:49 UTC


README

Реализованы только методы получения данных: https://topvisor.com/ru/api/v2/

Конфигурация

$config = [
    'components' => [
        'topvisor' => [
            'class' => dicr\topvisor\TopVisorApi::class,
            'userId' => '<UserID из личного кабинета>',
            'apiKey' => '<ключ API из личного кабинета>'
        ]
    ]
];

Использование

/** @var dicr\topvisor\TopVisorApi */
$api = Yii::$app->get('topvisor');

// получение списка проектов
/** @var dicr\topvisor\request\GetProjectsRequest $request */
$request = $api->request([
    'class' => dicr\topvisor\request\GetProjectsRequest::class,
    'fields' => ['id', 'name'],
    'limit' => 10
]);

// отправляем запрос
/** @var dicr\topvisor\request\GetProjectsResponse $response */
$response = $request->send();

// выводим результат
foreach ($response->result as $project) {
    echo 'Проект id=' . $project->id . ', name=' . $project->name . "\n";
}