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

小云云
Release: 2023-03-17 19:58:02
Original
2721 people have browsed it

Telegram’s notifications are just like text message reminders. 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. The point is, it’s free, there is no limit on the number of uses, and you don’t have to worry about censorship of text message content. Post whatever you want. In this article, we mainly introduce the use of Telegram’s interface in PHP to implement free message notification functions.

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:

The above content is about using Telegram’s interface to implement free message notification function in PHP. I hope it can help everyone.

Related recommendations:

javascript - segmentfault message notification reminder

Message notification plug-in based on HTML5 Notifications API

Counter implementation tutorial for message notification in Python’s Django framework

The above is the detailed content of Using Telegram's interface to implement free message notification function in PHP. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!