Created
June 2, 2018 19:13
-
-
Save rizkyramadhan21/6b739d8808f3848dab3bab951b67b722 to your computer and use it in GitHub Desktop.
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 | |
if($_SERVER['REQUEST_METHOD'] == "POST"){ | |
$secret_token = "TOKEN_BOT_TELEGRAM_ANDA"; | |
$telegram_id = $_POST ['telegram_id']; | |
$pesan_teks = $_POST ['pesan_teks']; | |
function sendMessage($telegram_id, $pesan_teks, $secret_token) { | |
$url = "https://api.telegram.org/bot" . $secret_token . "/sendMessage?chat_id=" . $telegram_id; | |
$url = $url . "&text=" . urlencode($pesan_teks); | |
$ch = curl_init(); | |
$optArray = array( | |
CURLOPT_URL => $url, | |
CURLOPT_RETURNTRANSFER => true | |
); | |
curl_setopt_array($ch, $optArray); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
} | |
sendMessage($telegram_id, $pesan_teks, $secret_token); | |
echo "<script>alert('Pesan berhasil terkirim!'); window.location.href = 'index_single_page.php';</script>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment