[g5] 텔레그램으로 메세지 발송 > 팁앤테크

본문 바로가기
사이트 내 전체검색

팁앤테크

[g5] 텔레그램으로 메세지 발송

페이지 정보

profile_image
작성자 제로
댓글 0건 조회 37,779회 작성일 21-05-17 17:06

본문

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;
    }
}
?>



// 텔레그램 PUSH 코드 실행
@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.']');


댓글목록

등록된 댓글이 없습니다.

Total 26건 1 페이지
  • RSS
팁앤테크 목록
번호 제목 글쓴이 조회 날짜
26 제로 55184 05-18
열람중 제로 37780 05-17
24 제로 47622 05-01
23 제로 59294 03-20
22 제로 71738 03-28
21 제로 70236 02-14
20 제로 69845 02-11
19 제로 67772 12-18
18 제로 42392 01-16
17 제로 42138 08-04
16 제로 41878 07-28
15 제로 40708 04-27
14 제로 58145 03-17
13 제로 44514 02-25
12 제로 83106 02-19
11 제로 42154 02-19
10 제로 43381 02-17
9 제로 43946 02-08
8 제로 40538 02-03
7 제로 42024 01-23
6 제로 61964 03-19
5 제로 56961 03-03
4 제로 43858 02-20
3 제로 38753 01-28
2 제로 45581 01-25

검색


사이트 정보

株式会社YHPLUS / 대표 : ZERO
〒140-0011 東京都品川区東大井2-5-9-203
050-5470-4714
오픈카카오톡 (YHPLUS) :
https://open.kakao.com/o/slfDj15d

접속자집계

오늘
14,735
어제
214,167
최대
552,140
전체
15,631,507
Copyright (c) 株式会社YHPLUS. All rights reserved.