Files
runnerbot/set.php
CM ace990e449 1st commit
1st commit
2021-04-17 17:53:59 +02:00

32 lines
802 B
PHP

<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
// Load composer
require __DIR__ . '/vendor/autoload.php';
$config = require __DIR__ . '/config.php';
$bot_api_key = $config['api_key'];
$bot_username = $config['bot_username'];
$hook_url = $config['webhook']['url'];
try {
// Create Telegram API object
$telegram = new Longman\TelegramBot\Telegram($bot_api_key, $bot_username);
// Set webhook
$result = $telegram->setWebhook($hook_url);
if ($result->isOk()) {
echo $result->getDescription();
}
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
// log telegram errors
// echo $e->getMessage();
}