티스토리 뷰

출처는

http://www.clien.net/cs2/bbs/board.php?bo_table=lecture&wr_id=303719

조금 더 자세한 https://nas.moe/archives/879 이 글들을 참고.


문제는 openssl 문제로 안되는 경우가 있는데, 이 글을 참고하여 약간 수정하면 된다.


<?php
    header("Content-Type: text/html; charset=utf-8");

    define('BOT_TOKEN', $_GET["bot_token"]);
    define('API_URL', 'https://api.telegram.org/bot'.BOT_TOKEN.'/');
     
    // grab the chatID
    $chatID = $_GET["chat_id"];
     
    // compose reply
    $reply =  sendMessage();
   
    $arrContextOptions=array(
        "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
        ),
    ); 
   
    // send reply
    $sendto = API_URL."sendmessage?chat_id=".$chatID."&text=".$reply;
    //file_get_contents($sendto);
    file_get_contents($sendto, false, stream_context_create($arrContextOptions));
     
    function sendMessage(){
    $message = urlencode($_GET["body"]);
    return $message;
    }
?>



'생활 속 > 홈서버' 카테고리의 다른 글

Synology ipkg 환경 설정  (1) 2016.01.19
Synology Transmission 백업  (1) 2016.01.19
RT-N56U에 nginx + PHP 올리기  (0) 2016.01.16
TS140에 Intel AMT와 ESXi 설정  (0) 2015.08.18
Intel NUC WOL 문제  (0) 2015.06.06
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함