1function sendMessage($chatID, $messaggio, $token) {
2 echo "sending message to " . $chatID . "\n";
3
4 $url = "https://api.telegram.org/bot" . $token . "/sendMessage?chat_id=" . $chatID;
5 $url = $url . "&text=" . urlencode($messaggio);
6 $ch = curl_init();
7 $optArray = array(
8 CURLOPT_URL => $url,
9 CURLOPT_RETURNTRANSFER => true
10 );
11 curl_setopt_array($ch, $optArray);
12 $result = curl_exec($ch);
13 curl_close($ch);
14 return $result;
15}
16
1$token = "<insert bot token here>";
2$chatid = "<chatID>";
3sendMessage($chatid, "Hello World", $token);
4