Download the PHP package lukasss93/telegrambot-php without Composer
On this page you can find all versions of the php package lukasss93/telegrambot-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lukasss93/telegrambot-php
More information about lukasss93/telegrambot-php
Files in lukasss93/telegrambot-php
Package telegrambot-php
Short Description Framework for Telegram Bot API
License MIT
Informations about the package telegrambot-php
⚠️ This package is abandoned and no longer maintained.
Please use the nutgram/nutgram package instead.
TelegramBot-PHP
A very simple PHP Telegram Bot API for sending messages.
Requirements
- PHP ≥ 7.2
- Curl for PHP must be enabled.
- Telegram API Key, you can get one simply with @BotFather with simple commands right after creating your bot.
For the WebHook:
- An SSL certificate (Telegram API requires this). You can use Cloudflare's Free Flexible SSL which crypts the web traffic from end user to their proxies if you're using CloudFlare DNS.
Since the August 29 update you can use a self-signed ssl certificate.
For the GetUpdates:
- Some way to execute the script in order to serve messages (for example cronjob)
Installation
You can install this library with composer:
composer require lukasss93/telegrambot-php
Configuration (WebHook)
Navigate to https://api.telegram.org/bot(TOKEN)/setWebhook?url=https://yoursite.com/your_update.php Or use the Telegram class setWebhook method.
Informations
This simple framework is object-based, all methods return a Telegram Object contained in TelegramBot/Types namespace.
Examples
If you want to get some specific parameter from the Telegram webhook, simply call parameter name in the object:
To upload a Photo or some other files, you need to load it with CurlFile:
To download a file on the Telegram's servers
If you want to use getUpdates instead of the WebHook you need a for cycle.
Message Object Methods
Message object mainly provide 2 methods:
-
getCommand()
- getArgs(bool $asString=false)
Build keyboard parameters
Telegram's bots can have two different kind of keyboards: Inline and Reply. The InlineKeyboard is linked to a particular message, while the ReplyKeyboard is linked to the whole chat. They are both an array of array of buttons, which rapresent the rows and columns. For instance you can arrange a ReplyKeyboard using this code:
When a user click on the button, the button text is send back to the bot. For an InlineKeyboard it's pretty much the same (but you need to provide a valid URL or a Callback data)
This is the list of all the helper functions to make keyboards easily:
Send a custom keyboard. $option is an array of array KeyboardButton.
Check ReplyKeyBoardMarkUp for more info.
Send a custom keyboard. $inline_keyboard is an array of array InlineKeyboardButton.
Check InlineKeyboardMarkup for more info.
Create an InlineKeyboardButton.
Check InlineKeyBoardButton for more info.
Create a KeyboardButton.
Check KeyBoardButton for more info.
Hide a custom keyboard.
Check ReplyKeyBoarHide for more info.
Show a Reply interface to the user.
Check ForceReply for more info.
Contact me
You can contact me via Telegram but if you have an issue please open one.
To-Do list
- Optional predictive parameters in methods
- Optimize keyboards
- Chat conversations
- Commands listener with callback + events
Changelog
All notable changes to this project will be documented here.
All versions of telegrambot-php with dependencies
ext-mbstring Version *
ext-curl Version *
ext-fileinfo Version *
ext-json Version *
netresearch/jsonmapper Version ^v4.0