Download the PHP package saber13812002/telegram-bale-bot-php without Composer
On this page you can find all versions of the php package saber13812002/telegram-bale-bot-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download saber13812002/telegram-bale-bot-php
More information about saber13812002/telegram-bale-bot-php
Files in saber13812002/telegram-bale-bot-php
Package telegram-bale-bot-php
Short Description A very simple PHP Telegram Bot API
License MIT
Informations about the package telegram-bale-bot-php
TelegramBotPHP
A very simple PHP Telegram Bot API.
Compliant with the April 16, 2022 Telegram Bot API update.
Requirements
- PHP >= 5.3
- Curl extension for PHP5 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 VALID 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(Long Polling):
- Some way to execute the script in order to serve messages (for example cronjob)
Download
Using Composer
From your project directory, run:
or
Note: If you don't have Composer you can download it HERE.
Using release archives
https://github.com/saber13812002/TelegramBotPHP/releases
Using Git
From a project directory, run:
Installation
Via Composer's autoloader
After downloading by using Composer, you can include Composer's autoloader:
Via TelegramBotPHP class
Copy Telegram.php into your server and include it in your new bot script:
Note: To enable error log file, also copy TelegramErrorLogger.php in the same directory of Telegram.php file.
Configuration (WebHook)
Navigate to https://api.telegram.org/bot(BOT_TOKEN)/setWebhook?url=https://yoursite.com/your_update.php Or use the Telegram class setWebhook method.
Examples
If you want to get some specific parameter from the Telegram response:
To upload a Photo or some other files, you need to load it with CurlFile:
To download a file on the Telegram's servers
See update.php or update cowsay.php for the complete example. If you wanna see the CowSay Bot in action add it.
If you want to use getUpdates instead of the WebHook you need to call the the serveUpdate
function inside a for cycle.
See getUpdates.php for the complete example.
Functions
For a complete and up-to-date functions documentation check http://eleirbag89.github.io/TelegramBotPHP/
Build keyboards
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 like this:
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.
Emoticons
For a list of emoticons to use in your bot messages, please refer to the column Bytes of this table: http://apps.timwhitlock.info/emoji/tables/unicode
License
This open-source software is distributed under the MIT License. See LICENSE.md
Contributing
All kinds of contributions are welcome - code, tests, documentation, bug reports, new features, etc...
- Send feedbacks.
- Submit bug reports.
- Write/Edit the documents.
- Fix bugs or add new features.
Contact me
You can contact me via Telegram but if you have an issue please open one.
Support me
You can support me using via LiberaPay
or buy me a beer or two using Paypal.
All versions of telegram-bale-bot-php with dependencies
ext-json Version *
ext-curl Version *