1. Go to this page and download the library: Download madmagestelegram/client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
madmagestelegram / client example snippets
// Basic client instance,
// its possible redefine guzzle client on second argument with own options, if necessary
$client = new \MadmagesTelegram\Client\Client('BOT_TOKEN');
// Chat id.
// Usually received in webhook or (https://core.telegram.org/bots/api#getupdates)
$chatId = 0;
// Simple text message
$client->sendMessage($chatId, 'Hello world');
// Simple text + disable message notification
$client->sendMessage($chatId, 'Here is silent message', null, null, null, true);
// It`s possible to send a file
$file = new \MadmagesTelegram\Types\Type\InputFile('/var/photos/some-photo.jpg');
// Here we can send "photo" as photo
$client->sendPhoto($chatId, $file);
// or document
$sentMessage = $client->sendDocument($chatId, $file);
// $sentMessage is instance of \MadmagesTelegram\Types\Type\Message
// As we send document in few lines upper, the property "document" is filled in returned message,
// so we can print it, accessing by getter
print_r($sentMessage->getDocument());
// it prints something like...
// MadmagesTelegram\Types\Type\Document Object
// (
// [fileId:protected] => ...
// [fileUniqueId:protected] => ...
// [thumb:protected] => ...
// [fileName:protected] => ...
// [mimeType:protected] => ...
// [fileSize:protected] => ...
// )
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.