import requests
url = "https://api.telegram.org/<BOTID>/sendPhoto";
files = {'photo': open('cctv.jpg', 'rb')}
data = {'chat_id' : "CHAT_ID"}
r= requests.post(url, files=files, data=data)
print(r.status_code, r.reason, r.content)
def sendImage():
url = "https://api.telegram.org/bot<Token>/sendPhoto";
files = {'photo': open('/path/to/img.jpg', 'rb')}
data = {'chat_id' : "YOUR_CHAT_ID"}
r= requests.post(url, files=files, data=data)
print(r.status_code, r.reason, r.content)
def sendImageRemoteFile(img_url):
url = "https://api.telegram.org/bot<Token>/sendPhoto";
remote_image = requests.get(img_url)
photo = io.BytesIO(remote_image.content)
photo.name = 'img.png'
files = {'photo': photo}
data = {'chat_id' : "YOUR_CHAT_ID"}
r= requests.post(url, files=files, data=data)
print(r.status_code, r.reason, r.content)
'Computer > Programing' 카테고리의 다른 글
Windows cd-key finder by VBS (0) | 2021.08.24 |
---|---|
MiTemp2 Read and write to SQL (0) | 2021.08.11 |
VS CODE (0) | 2020.03.01 |
Clien login python 클리앙 로그인 파이썬 (0) | 2019.02.07 |
Python data structure 파이썬 자료구조 (0) | 2019.02.07 |
Python load json from web (0) | 2019.02.07 |
Telegram URL 이용하여 문자 보내는법 (0) | 2019.02.07 |
Python 실행값을 PHP로 불러오기 (0) | 2019.02.07 |