Langsung saja ke contoh script untuk kirim pesan ke aplikasi Telegram menggunakan Jquery Ajax :
<script>
var pesan = 'Tes pesan ....!';
var myToken = "TOKEN_BOT_TELEGRAM";
var tlgId = "ID_TELEGRAM";
</script>
<p>Send Comment : <input type="button" value="submit" onclick="sendToTelegram(pesan,tlgId,myToken);"/></p>
<p><div id="result"/></p>
<script type='text/javascript'>
//<![CDATA[
function sendToTelegram(message,chatID,token){
var tlgUrl = "https://api.telegram.org/bot"+token+"/sendMessage?chat_id="+chatID+"&text="+message;
$.ajax({
url: tlgUrl,
type: "post",
dataType: "json",
success: function(data) {
//$.each(data, function(i,data){
$('#result').append('<b>SUKSES !</b>');
//});
},
error: function() {
$('#result').append('<b>ERROR !</b>');
}
});
}
//]]>
</script>
Selamat mencoba!
ConversionConversion EmoticonEmoticon