Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how send video note in telegram bot?

Tags:

telegram-bot

can any body help me to send video not in telegram bot؟

In fact, my problem is that when sending a video note is not sent in a circle. And it's sent as ordinary as sending a normal video. I followed all the necessary points are posted the video.

I uploaded the file in :

  • Mp4 format
  • Less than a minute
  • And is square.

And the code I've used:

the main function :

define('API_KEY','Token');

function bot($method,$datas=[]){
    $url = "https://api.telegram.org/bot".API_KEY."/".$method;
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($datas));
    $res = curl_exec($ch);
    if(curl_error($ch)){
        var_dump(curl_error($ch));
    }else{
        return json_decode($res);
    }
};

send video note :

 bot("sendVideoNote",[
    "chat_id"=>$chat_id,
    "video_note"=>$video_file_id,
      ]);

And with the place of this variable video_file_id ["file_id"], I used the direct address of the files, but I did not get any results in bot.

thanks for your helping...

like image 589
alex Avatar asked Oct 16 '25 03:10

alex


1 Answers

As stated in the Telegram Bot Api:

Sending video notes by a URL is currently unsupported.

This leads to video notes that are passed by an URL to be displayed as normal videos.

However, you can upload the file directly to create a real video note. Using CURLFile it would work as following:

$path = "path/to/video.mp4";
$realpath = realpath($path);

bot("sendVideoNote",[
    "chat_id" => $chat_id,
    "video_note"=> new CURLFile($realpath))
]);
like image 141
Maak Avatar answered Oct 18 '25 04:10

Maak