Oct. 29, 2022, 10:17 a.m.
Steps:
1. Search BotFather in Telegram
2. Create a newbot
3. Follow the instructions
4. Copy API Token
Steps:
1. Search BotFather in Telegram
2. Create a newbot
3. Follow the instructions
4. Copy API Token
import requests
import json
url = 'https://api.telegram.org/bot<Token>/getMe'
response = requests.post(url)
print(response)
data = response.json()
print(json.dumps(data,indent=4))
url2 = 'https://api.telegram.org/bot<Token>/getUpdates'
response2 = requests.post(url2)
print(response2)
data2 = response2.json()
print(json.dumps(data2,indent=4))
url3 = 'https://api.telegram.org/bot<Token>/sendMessage'
payload= {
"text":'Hi, How are you?',
"parse_mode": "HTML",
"reply_to_message_id": 2,
#Copy the chat id from the response of getUpdates method
"chat_id":chat_id
}
response3 = requests.post(url3, json=payload)
data3 = response.json()
print(data3)