Trouble Accessing Media Files from Telegram API Link in Aiogram

151 views Asked by At

I want to send photos and videos via telegram bot written in aiogram. But I encountered a problem with the link to this video/photo. My link looks like this: f"https://api.telegram.org/file/bot{bot.token}/{file_info.file_path}" The thing is that I can open this link in the browser and it will download. But as for automated systems, they simply can't reach this link Here's telegram log ( other automated systems didn't provide any error logs, they just show nothing ):

raise TelegramBadRequest(method=method, message=description)
aiogram.exceptions.TelegramBadRequest: Telegram server says - Bad Request: failed to get HTTP URL content

Here's my code snippet:

from aiogram import Bot, Dispatcher, F
from aiogram.types import Message
from config_new import BOT_TOKEN2
import asyncio 
from aiogram.filters import CommandStart

bot = Bot(BOT_TOKEN2)
dp = Dispatcher()

@dp.message(CommandStart())
async def start(msg: Message):
    ...
@dp.message(F.photo)
async def info(msg: Message):
    file_id = msg.photo[-1].file_id
    file_info = await bot.get_file(file_id)
    photo_url = f"https://api.telegram.org/file/bot{BOT_TOKEN2}/{file_info.file_path}"

asyncio.run(dp.start_polling(bot))
0

There are 0 answers