Installation
All the methods listed on Telegram Bot API page are fully supported by this SDK.
Standalone Setupโ
In order to use the library in your project, You need to install the SDK with Composer. Refer the Introduction page for more details on how to install with Composer and autoload in your project.
Initialize Libraryโ
The firstโ step is to initialize the library. Once you do that, You'll get access to all the available API Methods to make requests to Telegram.
use Telegram\Bot\Api;
$telegram = new Api('YOUR_BOT_TOKEN');
Laravel Setupโ
Open telegram.php
the configuration file in config
directory and set the bot_token
with your Telegram's Bot Access Token or you could also set environment variable TELEGRAM_BOT_TOKEN
with the appropriate value.
Refer the configuration file for other default configuration settings.
Config Overviewโ
Open the config file for detailed comments for each option.
Set your Telegram Bot Access Token in bot_token
key [REQUIRED]
'bot_token' => '1234:ABCD'
All other configs are optional, use as per your requirements.
Test Botโ
A simple method for testing your bot's auth token. Returns basic information about the bot in form of a User object.
See getMe docs for more details.
- Standalone
- Laravel
$response = $telegram->getMe();
$botId = $response->getId();
$firstName = $response->getFirstName();
$username = $response->getUsername();
$response = Telegram::getMe();
$botId = $response->getId();
$firstName = $response->getFirstName();
$username = $response->getUsername();