Добавил колбек

This commit is contained in:
Paradise 2020-09-13 11:47:34 +03:00
parent b3571bcecf
commit 3493000384
4 changed files with 67 additions and 2 deletions

View File

@ -54,3 +54,9 @@ USERAGENT = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, lik
# ID приложения ВК по умолчанию
APP_ID = '6660888'
# Домен сервера для подключения CallBack API
SERVER_DOMAIN =
# Произвольный ключ для подключения к CallBack серверу
CALLBACK_SECRET_KEY =

48
system/API/CallBack.php Normal file
View File

@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace VK\API;
class CallBack extends CallBackAbstract
{
/**
* Адрес для создания колбек-сервера
*
* @var string
*/
private $url;
/**
* Пользовательский ключ колбек-сессии
*
* @var string
*/
private $secret_key;
/**
* Ключ подтверждения колбек сессии
*
* @var string
*/
private $confirmation_token;
/**
* @var int
*/
private $group_id;
public function __construct(object $group, array $params = []){
$this->secret_key = $_ENV['CALLBACK_SECRET_KEY'];
$this->url = $_ENV['SERVER_DOMAIN'];
$this->group_id = $group->id;
$this->group_id->request('groups.addCallbackServer', [
'group_id' => $this->group_id,
'url' => $this->url,
'title' => $this->group_id . 'CallBackServer',
'secret_key' => $this->secret_key
]);
$this->confirmation_token = request('groups.getCallbackConfirmationCode', [$this->group_id]);
Curl::post($vk, [$this->confirmation_token]);
}
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace VK\API;
abstract class CallBackAbstract
{
abstract public function __construct(object $group, array $params = []);
}

View File

@ -81,6 +81,7 @@ class Group extends RobotAbstract
public function callback()
{
return new CallBack($this, $params);
}
protected function genToken(): string