Home >Backend Development >PHP Tutorial >How to write a free message notification function using the Telegram interface in PHP?
This article mainly introduces the free message notification function. How to write it using the Telegram interface in PHP? Interested friends can refer to it, I hope it will be helpful to everyone.
Using Telegram's interface, you can realize very convenient message reminders. There is no need to open the APP or scientifically connect to the Internet. Telegram's notifications are just like text message reminders.
The key point is that it is free, there is no limit on the number of uses, and you don’t have to worry about censorship of text message content. You can send whatever you want.
The following is the code for sending notifications using PHP:
<?php $bot_api_key = 'CHANGE HERE'; function send_get($urlstring){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $urlstring); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); $result = curl_exec($ch); curl_close($ch); return $result; } $text = @$_GET["text"]; $tgid = @$_GET["tgid"]; if($text){ $url = "https://api.telegram.org/bot$bot_api_key/sendMessage?chat_id=$tgid&text=$text"; echo send_get($url); }else{ echo "Please Input"; } ?>
Pass in two parameters, text and tgid.
Related recommendations:
Detailed explanation of the steps to implement drag-and-drop sorting through the php interface
Detailed explanation of the php interface programming
Detailed explanation of token in php interface
The above is the detailed content of How to write a free message notification function using the Telegram interface in PHP?. For more information, please follow other related articles on the PHP Chinese website!