Last active
May 22, 2021 12:14
-
-
Save rizkyramadhan21/5ac9d0848be91a403c6416d1326a69ca to your computer and use it in GitHub Desktop.
Simple php script for sending telegram bot message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* ----------------------------------------------------- | |
Simple PHP script for Sending Telegram Bot Message | |
~ Iky | https://www.wadagizig.com | |
------------------------------------------------------ */ | |
function sendMessage($telegram_id, $message_text, $secret_token) { | |
$url = "https://api.telegram.org/bot" . $secret_token . "/sendMessage?parse_mode=markdown&chat_id=" . $telegram_id; | |
$url = $url . "&text=" . urlencode($message_text); | |
$ch = curl_init(); | |
$optArray = array( | |
CURLOPT_URL => $url, | |
CURLOPT_RETURNTRANSFER => true | |
); | |
curl_setopt_array($ch, $optArray); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
} | |
/*---------------------- | |
only basic POST method : | |
-----------------------*/ | |
$telegram_id = $_POST ['telegram_id']; | |
$message_text = $_POST ['message_text']; | |
/*-------------------------------- | |
Isi TOKEN dibawah ini: | |
--------------------------------*/ | |
$secret_token = "Isi TOKEN disini"; | |
sendMessage($telegram_id, $message_text, $secret_token); | |
echo "<script>alert('Pesan berhasil terkirim!'); window.location.href = './';</script>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment