【问题标题】:How to get photo in real size (not thumb) from telegram?如何从电报中获取真实尺寸(不是拇指)的照片?
【发布时间】:2016-11-01 13:13:02
【问题描述】:

我正在使用 getFile() 然后下载带有https://api.telegram.org/file/bot<token>/<file_path>. 之类的链接的照片 但我只收到了他的缩略图

谁能问我如何下载真实尺寸的照片?

【问题讨论】:

  • 我通过 Android 移动应用程序“Telegram”上传 photp。只需将照片发送到我的机器人
  • 在尝试提出问题之前,请务必先通读您正在使用的 API 的文档。

标签: java api telegram-bot


【解决方案1】:

您从 Telegram 收到的 photo 对象包含一个具有不同大小的 file_id 的数组。索引越高,尺寸越大,所以你只需要选择正确的file_id .

它可能看起来像这样:

[{
    "file_id":"AgADBAADxxxx",
    "file_size":19374,
    "width":253,
    "height":320
},{
    "file_id":"AgADBAACxxxx",
    "file_size":75657,
    "width":632,
    "height":800
}]

【讨论】:

    【解决方案2】:

    如果你使用 PHP:你可以把这行写成全尺寸:

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

    还有这行拇指:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-28
      • 2013-08-22
      • 1970-01-01
      • 2015-12-31
      • 2014-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多