Download the PHP package smoqadam/php-telegram-bot without Composer
On this page you can find all versions of the php package smoqadam/php-telegram-bot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-telegram-bot
php-telegram-bot
A wrapper class for Telegram Bot API
Install
create composer.json :
$ composer install
How to use:
Smoqadam\Telegram
is a wrapper around Telegram bot API. After you instantiate Telegram
object, you can register callbacks on the updates you receive and then respond accordingly.
Register callbacks: Use following functions:
cmd()
, all normal messagesinlineQuery()
API Methods: The available methods are almost same of official Telegram API (for now the wrapper does not natively handles games and messages update):
sendMessage()
,getMe()
,forwardMessage()
,sendPhoto()
,sendVideo()
,sendSticker()
,sendLocation()
,sendDocument()
,sendAudio()
,sendChatAction()
,getUserProfilePhotos()
,answerInlineQuery()
Getting current update:
The current update is stored in the property Telegram::result
(that is an object).
Inline Result helper:
To facilitate the creation of Inline Bot there are some helper classes under namespace InlineQuery\Result
:
Article
Keyboards helper:
Also the same with keyboards; namespace is Keyboard
:
Standard
, classic keyboardRemove
, remove custom keyboard and show letter-keyboardInline
, inline keyboard
Use Keyboard:
Use the keyboard is pretty simple with helpers, after you instantiate keyboard (Standard
or Inline
) you use:
addButton()
addRow()
Note: These methods are chainable.
Example
Using long polling:
Using webHooks:
If you want to use webhooks you have to first call setWebhook
method or open the following URL with your own data:
https://api.telegram.org/API_TOKEN/setWebhook?url=https://yourdomain.com/index.php
please change API_TOKEN and url parameter
Now when you send /number 123
in telegram bot page , bot will answer to you your number is 123
You can set argument in regex between << and >>
Running bot
$ php index.php