How to get photo in real size (not thumb) from telegram?

后端 未结 2 1872
慢半拍i
慢半拍i 2021-01-29 07:47

I am using getFile() and then download photo with a link like https://api.telegram.org/file/bot/. But I received only his thumbnails

相关标签:
2条回答
  • 2021-01-29 08:28

    The photo object you receive from Telegram contains an array with the file_id of different sizes. The higher the index, the bigger the size, so you just need to pick the right file_id .

    It could look like this:

    [{
        "file_id":"AgADBAADxxxx",
        "file_size":19374,
        "width":253,
        "height":320
    },{
        "file_id":"AgADBAACxxxx",
        "file_size":75657,
        "width":632,
        "height":800
    }]
    
    0 讨论(0)
  • 2021-01-29 08:36

    if you use PHP: you can write this line for full size:

    $file_id = $updates['message']['photo'][1]['file_id'];

    and this line for thumb:

    $file_id = $updates['message']['photo'][0]['file_id'];

    0 讨论(0)
提交回复
热议问题