[g5] 텔레그램으로 메세지 발송
페이지 정보
본문
bbs/telegram_class.php
<?php
//https://api.telegram.org/bot봇Token값/getUpdates // chat_id 값
class telegram_msg {
private $chat_id = 'chat_id'; // id 값
private $bot_token = '봇Token값'; // token 값
function send($msg_id) {
//$msg = urlencode($this->set_msg($msg_id));
$msg = urlencode($msg_id);
$headers = array();
$headers[] = 'Content-type: Application/json';
$url = 'https://api.telegram.org/bot'.$this->bot_token.'/sendMessage?chat_id='.$this->chat_id.'&text='.$msg;
//file_put_contents(dirname(dirname(__DIR__)).'/private/telegram.log', $url.PHP_EOL, FILE_APPEND );
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_ENCODING, "");
curl_setopt($curl, CURLOPT_MAXREDIRS, 10);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
}
?>
@include_once(G5_BBS_PATH.'/telegram_class.php');
$telegram_msg = new telegram_msg();
$res = $telegram_msg->send($board['bo_subject'].'('.$board['bo_table'].' - '.$wr_id.') '.$wr_subject.' ['.$wr_name.']');
댓글목록
등록된 댓글이 없습니다.