forked from php-telegram-bot/example-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
set.php
33 lines (26 loc) · 881 Bytes
/
set.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
* README
* This file is intended to set the webhook.
* Uncommented parameters must be filled
*/
// Load composer
require_once __DIR__ . '/vendor/autoload.php';
// Add you bot's API key and name
$bot_api_key = 'your:bot_api_key';
$bot_username = 'username_bot';
// Define the URL to your hook.php file
$hook_url = 'https://your-domain/path/to/hook.php';
try {
// Create Telegram API object
$telegram = new Longman\TelegramBot\Telegram($bot_api_key, $bot_username);
// Set webhook
$result = $telegram->setWebhook($hook_url);
// To use a self-signed certificate, use this line instead
//$result = $telegram->setWebhook($hook_url, ['certificate' => $certificate_path]);
if ($result->isOk()) {
echo $result->getDescription();
}
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
echo $e->getMessage();
}