티스토리 뷰
반응형
package zitsm.framework.notice;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import zitsm.framework.exception.ZException;
public class ZTelegram {
public ZTelegram() throws ZException {
String Token = "tokenID";
String chat_id = "chart_id";
String text = "메시지 전송 테스트" ;
BufferedReader in = null;
try {
URL obj = new URL("https://api.telegram.org/bot" + Token + "/sendmessage?chat_id=" + chat_id + "&text=" + text); // 호출할 url
HttpURLConnection con = (HttpURLConnection)obj.openConnection();
con.setRequestMethod("GET");
in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
String line;
while((line = in.readLine()) != null) { // response를 차례대로 출력
System.out.println(line);
}
} catch(Exception e) {
e.printStackTrace();
} finally {
if(in != null) try { in.close(); } catch(Exception e) { e.printStackTrace(); }
}
}
}
텔레그램에 bot를 이용해서 메시지 보내는 java 샘플 소스이다.
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 덤프
- PPTX
- 대관령양떼목장
- jdk
- 오라클
- 부천역
- 인천여행
- java api
- 임자도
- 파주여행
- 보성녹차밭
- 산외한우마을
- pdf ms워드 변환
- ora-01940
- 인천
- oracle
- 밀리세컨드
- 제주도여행
- 테라로사
- 맛집
- 이클립스
- 가평여행
- 담양 죽녹원
- 가평팬션
- 정동지
- 토드
- 인스타그램
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함