
Подробнее о хостинге для размещения Телеграм бота можно узнать из статьи
Авторизуйтесь через Telegram, чтобы ответить.
Откройте бот @SiteAuthBot,
нажмите кнопку Старт/Start. Следуйте инструкциям бота.
{
"update_id": 932838882,
"message": {
"message_id": 1028316,
"from": {
"id": 448656663,
"is_bot": false,
"first_name": "amun ra",
"language_code": "ru"
},
"chat": {
"id": 448656663,
"first_name": "amun ra",
"type": "private"
},
"date": 1652081893,
"document": {
"file_name": "VPNlat_PRO_v3-8-3-6-4.apk",
"mime_type": "application/vnd.android.package-archive",
"thumb": {
"file_id": "AAMCAgADGQEAAQ-w3GJ4xOWfOpoMUFDanXkcfkCAi1hMAAIPFgACpGOQSV1ZQAABgZKp4gEAB20AAyQE",
"file_unique_id": "AQADDxYAAqRjkEly",
"file_size": 11547,
"width": 320,
"height": 320
},
"file_id": "BQACAgIAAxkBAAEPsNxieMTlnzqaDFBQ2p15HH5AgItYTAACDxYAAqRjkEldWUAAAYGSqeIkBA",
"file_unique_id": "AgADDxYAAqRjkEk",
"file_size": 11261552
},
"caption": "SHIELD 🛡 APK",
"caption_entities": [
{
"offset": 0,
"length": 13,
"type": "text_link",
"url": "https://t.me/ HddemnV2y3k3ZjM1"
}
]
}
}
"{"ok":true,"result":{"message_id":3213,"sender_chat":{"id":-1001320259426,"title":"TEST_CHANNEL_FOR_BOT","type":"channel"},"chat":{"id":-1001320259426,"title":"TEST_CHANNEL_FOR_BOT","type":"channel"},"date":1652094280,"document":{"file_name":"testfile.rar","mime_type":"application/vnd.rar","file_id":"BQACAgIZAx0EThj0-gACDI1iePVI9TS57WkVRVs57mNeBvoG0AACvBcAAjLbyEs6e9n9_tyNWiQE","file_unique_id":"AgADvBcAAjLbyEs","file_size":76}}}"
$postContent = [
'chat_id' => $chat_id,
'document' => new CURLFile($fileID),
'thumb' => [],
'caption' => 'caption'
];
$postContent['thumb'] = new CURLFile($thumb);
iMakeBots, спасибо, без тебя долго бы тупил. $postContent = [
'chat_id' => $chat_id,
'document' =>$fileID,
'thumb' => [],
'caption' => 'caption'
];
$postContent['thumb'] = new CURLFile($thumb);
$token = "5341363388:AAEVtyMYjidoI0Jxa10BBNWyVED5A16GcKY";
$chat_id = '-1001565144995';
$fileID = 'BQACAgIAAx0EXUo3owADB2J-QhN-gi64WF-j2qcVJjybMTyTAAJ6GgACQP35S94bMRqoj3UNJAQ';
$thumbURL = 'https://telegra.ph/file/0138a02ae64b42dc66f2d.jpg'; //ZIPpic
$postContent = ['chat_id' => $chat_id, 'document' => $fileID,];
$postContent['thumb'] = new CURLFile($thumbURL);
$request = botApiQuery('sendDocument', $postContent);
vаr_dump(json_decode($request));
function botApiQuery($method, $postContent)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://api.telegram.org/bot" . $GLOBALS['token'] . "/" . $method);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postContent);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: multipart/form-data']);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
$token = "5341363388:AAEVtyMYjidoI0Jxa10BBNWyVED5A16GcKY";
$chat_id = '-1001565144995';
$fileID = 'BQACAgIAAx0EXUo3owADB2J-QhN-gi64WF-j2qcVJjybMTyTAAJ6GgACQP35S94bMRqoj3UNJAQ';
$fileURL = 'https://www.dropbox.com/s/1mz3m40iblyn8cf/Social%20Media%20Icons%20and%20Buttons%20%282%29.rar?dl=1';
$thumbURL = 'https://telegra.ph/file/0138a02ae64b42dc66f2d.jpg'; //ZIPpic
$postContent = ['chat_id' => $chat_id, 'document' => new CURLFile($fileURL),];
$postContent['thumb'] = new CURLFile($thumbURL);
$request = botApiQuery('sendDocument', $postContent);
vаr_dump(json_decode($request));
function botApiQuery($method, $postContent)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://api.telegram.org/bot" . $GLOBALS['token'] . "/" . $method);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postContent);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: multipart/form-data']);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
$post = [
"chat_id" => "CHAT_ID",
// "document" => new \CURLFile("https://studentlib.com/skachat/referat-201582-razrabotka_i_issledovanie_modeli_otrazhatelya_modulyatora_winword_zip_1mb.zip"),
// "document" => new \CURLFile(__FILE__),
"document" => "BQACAgIAAxkDAAJEr2J_sNih-IEbpeY0hp3jgZgUPpdfAAL2FgACTfIBSIaEcgq3avwKJAQ",
"caption" => "Описание файла",
"thumb" => new \CURLFile("https://telegra.ph/file/0138a02ae64b42dc66f2d.jpg")
];
send($post, "TOKEN");
function send($fields, $token)
{
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.telegram.org/bot' . $token . '/sendDocument',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: multipart/form-data'],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $fields
]);
$result = json_decode(curl_exec($curl));
curl_close($curl);
return $result;
}
iMakeBots, подскажи plz решение.
Пытаюсь отправить методом sendDocument с превью. https://i.postimg.cc/kGb7fRNK/image.png
Бьюсь уже какой день.
Как вот сюда свое изображение вставить?
Json вот такой