ohctech_p8/telegram_send_file.php
2024-10-16 19:18:52 +05:30

43 lines
1.1 KiB
PHP

<?php
// Replace 'YOUR_BOT_TOKEN' with your actual bot token
$botToken = '6857726174:AAEhxZ5Tdxz2L4AW93rE5nbW1NiJLABBjAk';
$dipakMali = "1345765670";
$SitaramSir = "6921519567";
$chatIDs = array('1193810119', $SitaramSir);
// Path to the file you want to send
$filePath = "C:/Users/dusha/OneDrive/Desktop/blob.jpg";
// Telegram API URL
$url = "https://api.telegram.org/bot$botToken/sendDocument";
$text = 'Radhey Radhey';
foreach ($chatIDs as $chatID) {
$postFields = array(
'chat_id' => $chatID,
'document' => new CURLFile($filePath),
'caption' => $text
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
$headers = array('Content-Type: multipart/form-data');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
if ($response === false) {
echo 'Failed to send file to ' . $chatID . ': ' . curl_error($ch) . PHP_EOL;
} else {
echo 'File sent successfully to ' . $chatID . '!' . PHP_EOL;
}
}