-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from DJTommek/pr/set-webhook
Webhook $secret_token
- Loading branch information
Showing
2 changed files
with
42 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) { | ||
echo '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(); |
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