Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/birdra1n/senddocumentwithtextandbuttonlink
Bot Telegram with sending document, text and button using PHP
https://github.com/birdra1n/senddocumentwithtextandbuttonlink
curl php telegram-bot
Last synced: about 2 months ago
JSON representation
Bot Telegram with sending document, text and button using PHP
- Host: GitHub
- URL: https://github.com/birdra1n/senddocumentwithtextandbuttonlink
- Owner: BirdRa1n
- License: mit
- Created: 2021-10-08T19:59:32.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-08T20:16:33.000Z (about 3 years ago)
- Last Synced: 2024-04-24T05:59:32.374Z (8 months ago)
- Topics: curl, php, telegram-bot
- Language: PHP
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SendDocumentTelegramBot
* Envia Mensagem
* Documento
* Exibe um botão com hyperlink
~~~php
//$msg = strip_tags(nl2br($_POST['texto']));
$title = $_POST['title'];
$date = $_POST['delivery_date'];
$materia = $_POST['materia'];
$credts = $_POST['credts'];
$link = $_POST['link'];
$name_file = 'file.pdf';$msg = "Olá, Você está testando o meu código\nCréditos: TheDarioJr";
$token = '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: multipart/form-data']);
curl_setopt($ch, CURLOPT_URL, "https://api.telegram.org/bot{$token}/sendDocument");
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');$postFields = array(
'chat_id' => 'YourToken',
'document' => 'https://url_file' . "$name_file",
'caption' => $msg,
'reply_markup' => '{"inline_keyboard":[[{"text":"Button Link","url":"' . $link . '"}]]}'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
if (!curl_exec($ch))
echo curl_error($ch);
curl_close($ch);
~~~