Home > Backend Development > PHP Tutorial > Using Telegram's interface to implement free message notification function in PHP_php example

Using Telegram's interface to implement free message notification function in PHP_php example

韦小宝
Release: 2023-03-17 22:46:02
Original
3917 people have browsed it

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 = &#39;CHANGE HERE&#39;;
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";
}
?>
Copy after login


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

Based on PHP to implement the function of sending SMS when goods are sold php SMS verification code platform php SMS verification code software php SMS verification code pass

##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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template