Sending animated GIFs with sendPhoto (Telegram bot)

19,362

Solution 1

You should use the sendAnimation method for sending a GIF or H.264/MPEG-4 AVC video without sound.
Just use the animation parameter for your GIF file.


sendPhoto is only used for static images.

Solution 2

use sendVideo method!

https://api.telegram.org/bot<token>/sendVideo?chat_id=<chat_id>&video=http://i.giphy.com/13IC4LVeP5NGNi.gif

this will work

Share:
19,362

Related videos on Youtube

m52go
Author by

m52go

Updated on June 07, 2022

Comments

  • m52go
    m52go almost 2 years

    I'm trying to send an animated GIF with sendPhoto (Telegram's Bot API) with this request:

    https://api.telegram.org/bot<token>/sendPhoto?chat_id=<chat_id>&photo=http://i.giphy.com/13IC4LVeP5NGNi.gif
    

    That method works, as in, I get ok:true back, but the image in the chat window is a still snapshot of the moving GIF.

    How can I get the animated GIF to show? Is there another method I should use?

  • m52go
    m52go over 7 years
    OMG BRILLIANT!!!!!!!!!!!!! it does work. thanks, not sure why i didn't try it. just marked this as the correct answer.
  • Alvaro Gutierrez Perez
    Alvaro Gutierrez Perez about 7 years
    Please, mark this as the correct answer @m52go, as it is the recommended way. Also, even if you send it using sendVideo, you still get a document object back.
  • SimonGoldstone
    SimonGoldstone almost 6 years
    This worked for me. sendDocument didn't (I'm using the c# nuget package)
  • Nikita_kharkov_ua
    Nikita_kharkov_ua over 5 years
    Yes, sure you can use sendDocument and it works on desktop, but on the mobile you will face with problem when you see only preview of gif, not a gif at once. If you use sendVideo - both good on a desktop and mobile.
  • Rushikant Pawar
    Rushikant Pawar almost 4 years
    What if a image or video is from local disc?