Download the PHP package parsapoorsh/telegrambotphp without Composer
On this page you can find all versions of the php package parsapoorsh/telegrambotphp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download parsapoorsh/telegrambotphp
More information about parsapoorsh/telegrambotphp
Files in parsapoorsh/telegrambotphp
Package telegrambotphp
Short Description A very simple PHP Telegram Bot API
License MIT
Informations about the package telegrambotphp
TelegramBotPHP
A very simple PHP Telegram Bot API.
Compliant with the April 21, 2023 Telegram Bot API update.
Requirements
- PHP >= 7.4
- Curl extension for PHP7 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/parsapoorsh/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 want to see the CowSay Bot in action add it.
If you want to use getUpdates instead of the WebHook you need to call the serveUpdate
function inside a for cycle.
See getUpdates.php for the complete example.
Functions
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 represent 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.
About fork
This repo is based on Eleirbag89/TelegramBotPHP. I forked it because the main repo hadn't been updated for 10 months while Telegram Bot API had 8 updates during that time.
Contact me
You can contact me via Telegram but if you have an issue please open one.
All versions of telegrambotphp with dependencies
ext-json Version *
ext-curl Version *