• 카테고리

    질문 & 답변
  • 세부 분야

    업무 자동화

  • 해결 여부

    미해결

텔레그램 sendMessage 시 400에러가 뜹니다.

24.07.04 12:30 작성 24.07.04 12:32 수정 조회수 35

0

message = input("message: ")

data = {"chat_id":chat_id, "text":message}

url = f"http://api.telegram.org/bot{bot_token}/sendMessage"
res = requests.get(url, data=data)

print(res)
if res.status_code == 200:
    print(json.loads(res.text))

위처럼 작성하고 실행해보면 response 400에러가 발생합니다.

getUpdate 메서드는 정상실행이 되는데 뭐가 문제인지 모르겠습니다....

url 공백이 있으면 400에러가 발생한다고 검색은 해봤는데 , 전 공백도 없는것 같고.

답변 1

답변을 작성해보세요.

0

import requests
import json
import telegram
import asyncio
bot_token="?"
chat_id="?"

bot = telegram.Bot(bot_token)
asyncio.run(bot.sendMessage(chat_id=chat_id, text = "message"))

인터넷으로 서칭해서 이렇게는 동작하는거 확인했습니다.

수업 내용에서 현 시점에 뭔가 변경된게 있는걸까요?

채널톡 아이콘