You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

1 year ago
  1. <?php
  2. /**
  3. * This file is part of the PHP Telegram Bot example-bot package.
  4. * https://github.com/php-telegram-bot/example-bot/
  5. *
  6. * (c) PHP Telegram Bot Team
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. /**
  12. * This file is used to set the webhook.
  13. */
  14. // Load composer
  15. require_once __DIR__ . '/vendor/autoload.php';
  16. // Load all configuration options
  17. /** @var array $config */
  18. $config = require __DIR__ . '/config.php';
  19. try {
  20. // Create Telegram API object
  21. $telegram = new Longman\TelegramBot\Telegram($config['api_key'], $config['bot_username']);
  22. /**
  23. * REMEMBER to define the URL to your hook.php file in:
  24. * config.php: ['webhook']['url'] => 'https://your-domain/path/to/hook.php'
  25. */
  26. // Set the webhook
  27. $result = $telegram->setWebhook($config['webhook']['url']);
  28. // To use a self-signed certificate, use this line instead
  29. // $result = $telegram->setWebhook($config['webhook']['url'], ['certificate' => $config['webhook']['certificate']]);
  30. echo $result->getDescription();
  31. } catch (Longman\TelegramBot\Exception\TelegramException $e) {
  32. echo $e->getMessage();
  33. }