How to write a free message notification function using the Telegram interface in PHP?

墨辰丷
Release: 2023-03-26 07:36:02
Original
1854 people have browsed it

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 = &#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.

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!

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!