如何用PHP改写Telegram接口实现免费消息通知功能?
- 内容介绍
- 文章标签
- 相关推荐
本文共计408个文字,预计阅读时间需要2分钟。
利用Telegram接口,轻松实现消息提醒,无需打开APP,无需科学上网,就像短信提醒一样。重点是,免费使用,无使用数量限制,无需担心短信内容审核。你想要实现什么?
利用Telegram的接口,可以实现很方便的消息提醒,不用打开APP,不用科学联网,Telegram的通知就像短信提醒一样。
重点是,免费,无使用数量限制,不用担心短信内容审 查,你想发什么就发什么。
下面是利用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 = "api.telegram.org/bot$bot_api_key/sendMessage?chat_id=$tgid&text=$text"; echo send_get($url); }else{ echo "Please Input"; } ?>
传入两个参数,text和tgid。
本文共计408个文字,预计阅读时间需要2分钟。
利用Telegram接口,轻松实现消息提醒,无需打开APP,无需科学上网,就像短信提醒一样。重点是,免费使用,无使用数量限制,无需担心短信内容审核。你想要实现什么?
利用Telegram的接口,可以实现很方便的消息提醒,不用打开APP,不用科学联网,Telegram的通知就像短信提醒一样。
重点是,免费,无使用数量限制,不用担心短信内容审 查,你想发什么就发什么。
下面是利用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 = "api.telegram.org/bot$bot_api_key/sendMessage?chat_id=$tgid&text=$text"; echo send_get($url); }else{ echo "Please Input"; } ?>
传入两个参数,text和tgid。

