0

I used this code to send image via BOT found here https://stackoverflow.com/a/32296353/6017365, all work great:

$bot_url    = "https://api.telegram.org/bot<bot_id>/";
$url        = $bot_url . "sendPhoto?chat_id=" . $chat_id ;

$post_fields = array('chat_id'   => $chat_id,
    'photo'     => new CURLFile(realpath("/path/to/image.png"))
);

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Content-Type:multipart/form-data"
));
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); 
$output = curl_exec($ch);

Then I modified it to send gif with sendVideo and video parameters.

Now i'd like to edit file to send normal text with gif as attachment....I tried to add text parameters in the array, but only image is received... Any suggest?

Giuseppe Lodi Rizzini
  • 1,045
  • 11
  • 33
  • 3
    Try using `caption` instead of `text` (text is for text message & caption is for photos and videos & photo albums) – Ali Khalili Nov 08 '19 at 08:57

1 Answers1

1

Just to clarify @AliKhalili's response;

sendVideo accepts a optional parameter called caption to add some text to a video.

Unlike sendMessage that used the required text field.

0stone0
  • 34,288
  • 4
  • 39
  • 64