Home > Article > Backend Development > Using Telegram's interface to implement free message notification function in PHP_php example
This article mainly introduces the use of Telegram's interface in PHP to implement free message notification functions. Telegram's notifications are just like SMS reminders. Specific implementationPHP codePlease refer to this article
Using Telegram’s interface, you can achieve very convenient message reminders. You don’t need to open the APP or scientifically connect to the Internet. Telegram’s notifications are just like SMS 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.
tgid is the tg account ID that needs to receive messages. You can search for my robot @libinbinBot, and then send /myid to get your id.
The telegram interface format used here is:
https://api.telegram.org/bot[bot_api_key]/sendMessage?chat_id=[tgid]&text=[text]
The interface is simple and the call is very easy, and it is free without any restrictions.
The picture below is my tg interface, with customized product price reduction reminders and project ISSSUES library reminders:
Summary
The above is the implementation of the Telegram interface in PHP introduced by the editor Free message notification function, I hope it will be helpful to everyone! !
Related recommendations:
##php SMS interface code, php SMS interface_PHP tutorial
The above is the detailed content of Using Telegram's interface to implement free message notification function in PHP_php example. For more information, please follow other related articles on the PHP Chinese website!