First Creating a new bot -> via https://t.me/botfather
Use the /newbot command to create a new bot. The BotFather will ask you for a name and username, then generate an authentication token for your new bot.
The name of your bot is displayed in contact details and elsewhere.
The Username is a short name, to be used in mentions and t.me links. Usernames are 5-32 characters long and are case insensitive, but may only include Latin characters, numbers, and underscores. Your bot's username must end in 'bot', e.g. 'tetris_bot' or 'TetrisBot'.
The token is a string along the lines of 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw that is required to authorize the bot and send requests to the Bot API. Keep your token secure and store it safely, it can be used by anyone to control your bot.
BotFather, [09-08-2022 11:43]
Alright, a new bot. How are we going to call it? Please choose a name for your bot.
MARC, [09-08-2022 11:44]
oracle-cloud
BotFather, [09-08-2022 11:44]
Good. Now let's choose a username for your bot. It must end in bot
. Like this, for example: TetrisBot or tetris_bot.
yourbotname_bot
Done! Congratulations on your new bot. You will find it at t.me/yourbotname_bot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.
Use this token to access the HTTP API:
5489378422:AAGZ9FRCkZorhHdhd&hd83JVe4XoIrve_E
Keep your token secure and store it safely, it can be used by
Get Update and chat ID
https://api.telegram.org/bot5489378422:AAGZ9FRCkZorhHdhd&hd83JVe4XoIrve_E/getUpdates
Send Message via HTTP API
https://api.telegram.org/bot5489378422:AAGZ9FRCkZorhHdhd&hd83JVe4XoIrve_E/sendMessage?chat_id=102456789&text=HIIIII
VIA PHP Function
vi func.php
<?php
function sendMessage($chatID, $messaggio, $token) {
echo "sending message to " . $chatID . "\n";
$url = "https://api.telegram.org/bot" . $token . "/sendMessage?chat_id=" . $chatID;
$url = $url . "&text=" . urlencode($messaggio);
$ch = curl_init();
$optArray = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $optArray);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
?>
vi send.php
<?php
include("func.php");
$token = "5489378422:AAGZ9FRCkZorhHdhd&hd83JVe4XoIrve_E";
$chatid = "102456789";
sendMessage($chatid, "Oracle DB is Down", $token);
?>