forked from ijulhaxor/portfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendMessage.php
45 lines (36 loc) · 1.12 KB
/
sendMessage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/*--------------------------------
Isi TOKEN dan Chat ID dibawah ini:
--------------------------------*/
$telegram_id = '0123456789';
$secret_token = "bot:token";
/* -----------------------------------------------------
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 :
-----------------------*/
$nama = $_POST['nama'];
$email = $_POST['email'];
$pesan = $_POST ['pesan'];
$message_text = "```
Nama : $nama
Email : $email
Pesan :
$pesan```";
sendMessage($telegram_id, $message_text, $secret_token);
Header('Location: ./')
?>