Last active
August 26, 2023 03:06
-
-
Save rizkytegar/c795e8622c2ea3b0e99abe7d93cc6d15 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 | |
$token = "xx:xxx"; | |
$telegram_id = "xxx"; | |
$text = "Ini adalah notifikasi dari website."; | |
$url = "https://api.telegram.org/bot" . $token . "/sendMessage"; | |
$data = array( | |
'chat_id' => $telegram_id, | |
'text' => $text | |
); | |
$options = array( | |
'http' => array( | |
'method' => 'POST', | |
'header' => "Content-Type: application/x-www-form-urlencoded\r\n", | |
'content' => http_build_query($data) | |
) | |
); | |
$context = stream_context_create($options); | |
$result = file_get_contents($url, false, $context); | |
if ($result === false) { | |
echo "Gagal mengirim notifikasi."; | |
} else { | |
echo "Notifikasi berhasil dikirim."; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment