Skip to content

Instantly share code, notes, and snippets.

@LeonelF
Created June 9, 2021 14:37
Show Gist options
  • Save LeonelF/42932479fdf52bfe1e3c28d27a669c84 to your computer and use it in GitHub Desktop.
Save LeonelF/42932479fdf52bfe1e3c28d27a669c84 to your computer and use it in GitHub Desktop.
<?php
function telegram($chat_id,$message) {
$botToken = "BOT TOKEN HERE";
$url="https://api.telegram.org/bot". $botToken ."/sendMessage";
$params= array('chat_id' => $chat_id, 'parse_mode' => 'HTML', 'text' => $message);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
}
//Usage
telegram(CHATID,"<b>TESTE MESSAGE</b>". chr(10) ."NAICE: <b>IT WORKS!</b>");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment