Sending animated GIFs with sendPhoto (Telegram bot)
Asked Answered
M

3

13

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?

Mesdames answered 15/12, 2016 at 18:51 Comment(1)
Nowadays method sendAnimation is the best option.Cardialgia
P
25

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.

Poignant answered 15/12, 2016 at 20:3 Comment(2)
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.Brassbound
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.Lithic
N
15

use sendVideo method!

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

this will work

Neil answered 6/2, 2017 at 16:20 Comment(4)
OMG BRILLIANT!!!!!!!!!!!!! it does work. thanks, not sure why i didn't try it. just marked this as the correct answer.Mesdames
This worked for me. sendDocument didn't (I'm using the c# nuget package)Willner
What if a image or video is from local disc?Murphy
How to run this code in python?Discreditable
P
0

description photo for the bot, 640x360 pixels. Or a GIF, 320x180, 640x360 or 960x540 pixels. People will see this photo or GIF when they open a chat with your bot, in a block titled 'What can this bot do?'. Use /empty to remove the current picture.

Proportional answered 14/5 at 11:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.