Sending video notes to multiple users using Telegram Bot API results in 404 error for subsequent requests

I’m trying to send a video note to multiple Telegram users using the Telegram Bot API, but I’m encountering an issue where the first request succeeds and all subsequent requests return a 404 “Not Found” error. Here’s the PHP code I’m using to send these video notes:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>$apiURLBase = "https://api.telegram.org/bot<YourBotToken>/";
$selectedUsers = ['111111111', '2222222222']; // Example chat IDs
$originalVideoPath = 'path_to_your_video.mp4';
foreach ($selectedUsers as $chatId) {
$uniqueFilePath = 'video_notes/' . uniqid() . '.mp4';
copy($originalVideoPath, $uniqueFilePath); // Ensure a unique file for each request
$apiURL = $apiURLBase . "sendVideoNote";
$video_note = new CURLFile($uniqueFilePath);
$data = [
'chat_id' => $chatId,
'video_note' => $video_note
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:multipart/form-data"));
curl_setopt($ch, CURLOPT_URL, $apiURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
curl_close($ch);
unlink($uniqueFilePath); // Clean up the temporary file
echo "Response for chat_id $chatId: " . $output . "<br>";
}
</code>
<code>$apiURLBase = "https://api.telegram.org/bot<YourBotToken>/"; $selectedUsers = ['111111111', '2222222222']; // Example chat IDs $originalVideoPath = 'path_to_your_video.mp4'; foreach ($selectedUsers as $chatId) { $uniqueFilePath = 'video_notes/' . uniqid() . '.mp4'; copy($originalVideoPath, $uniqueFilePath); // Ensure a unique file for each request $apiURL = $apiURLBase . "sendVideoNote"; $video_note = new CURLFile($uniqueFilePath); $data = [ 'chat_id' => $chatId, 'video_note' => $video_note ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:multipart/form-data")); curl_setopt($ch, CURLOPT_URL, $apiURL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $output = curl_exec($ch); curl_close($ch); unlink($uniqueFilePath); // Clean up the temporary file echo "Response for chat_id $chatId: " . $output . "<br>"; } </code>
$apiURLBase = "https://api.telegram.org/bot<YourBotToken>/";
$selectedUsers = ['111111111', '2222222222']; // Example chat IDs
$originalVideoPath = 'path_to_your_video.mp4';

foreach ($selectedUsers as $chatId) {
    $uniqueFilePath = 'video_notes/' . uniqid() . '.mp4';
    copy($originalVideoPath, $uniqueFilePath); // Ensure a unique file for each request

    $apiURL = $apiURLBase . "sendVideoNote";
    $video_note = new CURLFile($uniqueFilePath);

    $data = [
        'chat_id' => $chatId,
        'video_note' => $video_note
    ];

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

    unlink($uniqueFilePath); // Clean up the temporary file

    echo "Response for chat_id $chatId: " . $output . "<br>";
}

Expected behavior:

I expect the video note to be sent to all users in the $selectedUsers array without any issues.

Actual behavior:

The first user in the array receives the video note successfully, but for the second user, I receive the following response from the Telegram API:

{“ok”:false,”error_code”:404,”description”:”Not Found”}

Additional details:

The video files are ensured to be unique for each request by copying them to a new file with a unique name.
The problem persists even after adding a delay between requests using sleep(1);.
All other parameters and settings (such as API URLs, bot token, etc.) have been double-checked for accuracy.

Could anyone help identify why subsequent requests are failing and how to fix this issue?

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật