本篇文章主要介绍免费的消息通知功能,用php中telegram的接口怎么写?感兴趣的朋友参考下,希望对大家有所帮助。
利用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 = "https://api.telegram.org/bot$bot_api_key/sendmessage?chat_id=$tgid&text=$text";
echo send_get($url);
}else{
echo "please input";
}
?>
传入两个参数,text和tgid。
相关推荐:
php接口实现拖拽排序步骤详解
php接口编程详解
php接口的token详解
以上就是免费的消息通知功能,用php中telegram的接口怎么写?的详细内容。