Skip to content

Commit c743843

Browse files
committed
FIX set webhook bug
1 parent e5d6c3a commit c743843

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,26 @@ You must set a [WebHook](https://core.telegram.org/bots/api#setwebhook)
128128
Create *set.php* (just edit *example-set.php*) and put into it:
129129
```php
130130
<?php
131+
//Composer Loader
131132
$loader = require __DIR__.'/vendor/autoload.php';
132133

133134
$API_KEY = 'your_bot_api_key';
134135
$BOT_NAME = 'namebot';
135-
136+
$link = 'https://yourdomain/yourpath_to_hook.php';
136137
try {
137138
// create Telegram API object
138139
$telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
139140
// set webhook
140-
echo $telegram->setWebHook('https://yourdomain/yourpath_to_hook.php');
141+
$result = $telegram->setWebHook($link);
142+
if ($result->isOk()) {
143+
echo $result->getDescription();
144+
}
141145
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
142146
echo $e->getMessage();
143147
}
148+
149+
150+
144151
```
145152
And open your *set.php* via browser.
146153

example-set.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44

55
$API_KEY = 'your_bot_api_key';
66
$BOT_NAME = 'namebot';
7-
7+
$link = 'https://yourdomain/yourpath_to_hook.php';
88
try {
99
// create Telegram API object
1010
$telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
1111
// set webhook
12-
echo $telegram->setWebHook('https://yourdomain/yourpath_to_hook.php');
12+
$result = $telegram->setWebHook($link);
13+
if ($result->isOk()) {
14+
echo $result->getDescription();
15+
}
1316
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
1417
echo $e->getMessage();
1518
}

0 commit comments

Comments
 (0)