Добавил колбек
This commit is contained in:
parent
b3571bcecf
commit
3493000384
|
@ -53,4 +53,10 @@ ACCESS_GROUPS="notify,friends,photos,audio,video,stories,pages,status,notes,mess
|
|||
USERAGENT = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36'
|
||||
|
||||
# ID приложения ВК по умолчанию
|
||||
APP_ID = '6660888'
|
||||
APP_ID = '6660888'
|
||||
|
||||
# Домен сервера для подключения CallBack API
|
||||
SERVER_DOMAIN =
|
||||
|
||||
# Произвольный ключ для подключения к CallBack серверу
|
||||
CALLBACK_SECRET_KEY =
|
|
@ -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]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace VK\API;
|
||||
|
||||
abstract class CallBackAbstract
|
||||
{
|
||||
abstract public function __construct(object $group, array $params = []);
|
||||
}
|
|
@ -76,11 +76,12 @@ class Group extends RobotAbstract
|
|||
|
||||
public function longpoll(...$params): LongPoll
|
||||
{
|
||||
return new LongPoll($this, $params);
|
||||
return new LongPoll($this, $params);
|
||||
}
|
||||
|
||||
public function callback()
|
||||
{
|
||||
return new CallBack($this, $params);
|
||||
}
|
||||
|
||||
protected function genToken(): string
|
||||
|
|
Loading…
Reference in New Issue