-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Webhook: added example for SetWebook class
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
include __DIR__ . '/basics.php'; | ||
|
||
use React\EventLoop\Factory; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
use unreal4u\TelegramAPI\HttpClientRequestHandler; | ||
use unreal4u\TelegramAPI\Telegram\Methods\SetWebhook; | ||
use unreal4u\TelegramAPI\TgLog; | ||
|
||
$loop = Factory::create(); | ||
$tgLog = new TgLog(BOT_TOKEN, new HttpClientRequestHandler($loop)); | ||
|
||
$webhook = new SetWebhook(); | ||
$webhook->url = 'https://example.com/'; | ||
$webhook->max_connections = 3; | ||
$webhook->allowed_updates = ['message']; | ||
$webhook->drop_pending_updates = true; | ||
$webhook->secret_token = 'some-very-secret-string'; | ||
|
||
$promise = $tgLog->performApiRequest($webhook); | ||
$promise->then( | ||
function (TelegramTypes $response) { | ||
var_dump('Webhook was successfully set. Run get-webhookinfo.php to get detailed information about webhook from server.'); | ||
}, | ||
function (\Exception $exception) { | ||
var_dump($exception->getMessage()); | ||
} | ||
); | ||
|
||
$loop->run(); |