$params = [ 'url' => '', 'certificate' => '', ];
public function setWebhook(array $params) { if (filter_var($params['url'], FILTER_VALIDATE_URL) === false) { throw new TelegramSDKException('Invalid URL Provided'); } if (parse_url($params['url'], PHP_URL_SCHEME) !== 'https') { throw new TelegramSDKException('Invalid URL, should be a HTTPS url.'); } return $this->uploadFile('setWebhook', $params); }
/** * App constructor. */ public function __construct() { parent::__construct(); $this->match('/', function () { return '/'; }); /** * process messages */ $this->match('update', function () { $telegram = new Client(BOT_TOKEN); $handler = new Handler($telegram); return $handler->handle(); }); /** * update hook settings/api */ $this->match('hook', function () { $telegram = new Api(BOT_TOKEN); $telegram->removeWebhook(); if (USE_WEBHOOK) { $telegram->setWebhook(WEBHOOK, '../server-setup/files/cert/nginx.crt'); return 'hook set'; } return 'hook-removed'; }); }