Skip to content

Instantly share code, notes, and snippets.

@rizkyramadhan21
Created June 2, 2018 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rizkyramadhan21/6b739d8808f3848dab3bab951b67b722 to your computer and use it in GitHub Desktop.
Save rizkyramadhan21/6b739d8808f3848dab3bab951b67b722 to your computer and use it in GitHub Desktop.
<?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