52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace VK\Robots;
|
||
|
|
||
|
class User extends RobotAbstract
|
||
|
{
|
||
|
/**
|
||
|
* Токен авторизации
|
||
|
*/
|
||
|
public string $token;
|
||
|
|
||
|
/**
|
||
|
* Версия используемого API
|
||
|
*/
|
||
|
public float $version;
|
||
|
|
||
|
/**
|
||
|
* Конструктор робота категории: "Пользователь"
|
||
|
*
|
||
|
* Предназначен для работы от лица пользователя ВКонтакте
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function __construct() {
|
||
|
$this->auth();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Метод авторизации робота
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function auth(string $token, float $version)
|
||
|
{
|
||
|
if ($token instanceof auth) {
|
||
|
$this->auth = $token;
|
||
|
$this->version = $version;
|
||
|
$this->token = $this->auth->getAccessToken();
|
||
|
} else if (isset($also_version)) {
|
||
|
$this->auth = new Auth($token, $version);
|
||
|
$this->token = $this->auth->getAccessToken();
|
||
|
$this->version = $also_version;
|
||
|
} else {
|
||
|
$this->token = $token;
|
||
|
$this->version = $version;
|
||
|
}
|
||
|
$this->data = json_decode(file_get_contents('php://input'));
|
||
|
}
|
||
|
}
|