skip to Main Content

Telegram bot api supports sending an already uploaded photo. Does telegram api also support sending an already uploaded photo?

I looked at the api documentation but couldn’t find any relevant method.

2

Answers


  1. You can obtain file_id in response of sendPhoto, just use it as photo field like chat_id.

    For instance:

    callAPI("sendPhoto", [
        "chat_id": 109780439,
        "file_id": "AAAAAAXXX"
    ]
    
    Login or Signup to reply.
  2. if you use this lib https://github.com/TelegramBot/Api, it’s working code:

    $chat_id = <chat_id>;
    $token = <token>;
    $bot = new TelegramBotApiBotApi($token);
    
    try {
    
        $bot->sendPhoto($chat_id, <file_id>, 'caption');
    
    } catch (TelegramBotApiException $e) {
    
        $e->getMessage();
    
    }
    

    if not, this is simple GET method:

    https://api.telegram.org/bot<token>/sendPhoto?chat_id=<chat_id>&photo=<file_id>
    

    more info Telegram Bot API

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search