Detailed explanation of using Telegram's interface to implement free message notification function in PHP

jacklove
Release: 2023-04-02 19:20:02
Original
3316 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. Please refer to this article for the specific implementation code

Using Telegram’s interface, you can achieve very convenient message reminders. There is no 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. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the php Chinese website!

Related recommendations:

Detailed explanation of Naive Bayes algorithm for machine learning in PHP

PHP implements singly linked list flip operation Example explanation

PHP method to merge two ordered arrays

The above is the detailed content of Detailed explanation 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!