Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/formapro/telegram-bot-php
PHP Telegram Bot.
https://github.com/formapro/telegram-bot-php
php7 telegram telegram-bot
Last synced: 5 days ago
JSON representation
PHP Telegram Bot.
- Host: GitHub
- URL: https://github.com/formapro/telegram-bot-php
- Owner: formapro
- License: mit
- Created: 2019-01-08T08:50:44.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-06T20:53:23.000Z (over 3 years ago)
- Last Synced: 2024-04-24T18:55:31.281Z (9 months ago)
- Topics: php7, telegram, telegram-bot
- Language: PHP
- Size: 51.8 KB
- Stars: 252
- Watchers: 17
- Forks: 61
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Telegram Bot
Telegram bot as it should be.
## Examples
### SetWebhook
```php
setCertificate(file_get_contents('/path/to/self-signed-certifcate.pem'));$response = $bot->setWebhook($setWebhook);
echo str($response);
```### GetWebhookInfo
```php
getWebhookInfo();echo str($response);
```### SendMessage
```php
sendMessage(new SendMessage(
$update->getMessage()->getChat()->getId(),
'Hi there! What can I do?'
));
```### SendPhoto
**Note:** if you want to send gif with many pictures inside -
use `sendDocument````php
getMessage()->getChat()->getId(),
file_get_contents($picture) // or just $picture if it's url
);// also you can set `caption` to image
$sendPhoto->setCaption('Some caption under the picture');$bot = new Bot('telegramToken');
$bot->sendPhoto($sendPhoto);
```### SendDocument
**Note:** _sending by URL will currently only work for
gif, pdf and zip files._ (from documentation)```php
getMessage()->getChat()->getId(),
$document
);// also you can set `caption` to image
$sendDocument->setCaption('Some caption under the document');$bot = new Bot('telegramToken');
$bot->sendDocument($sendDocument);
```### SendInvoice
```php
getMessage()->getChat()->getId(),
'Your title',
'Your description of invoice',
json_encode($payload),
$providerToken,
'12314czasdq', // unique id
'UAH',
[new LabeledPrice('PriceLabel_1', 3001)] // amount; here 30.01 UAH
);$bot = new Bot('telegramToken');
$bot->sendInvoice($sendInvoice);
```### ReplyKeyboardMarkup
```php
getMessage()->getChat()->getId(), 'Choose an option.');
$sendMessage->setReplyMarkup($keyboard);$bot = new Bot('telegramToken');
$bot->sendMessage($sendMessage);
```Request Contacts:
```php
setRequestContact(true);
$keyboard = new ReplyKeyboardMarkup([[$button]]);
$keyboard->setOneTimeKeyboard(true);$sendMessage = new SendMessage($update->getMessage()->getChat()->getId(), 'Please, share your contact info with us.');
$sendMessage->setReplyMarkup($keyboard);$bot = new Bot('telegramToken');
$bot->sendMessage($sendMessage);
```### InlineKeyboardButton
Url:
```php
getMessage()->getChat()->getId(), 'Click on inline button.');
$sendMessage->setReplyMarkup($keyboard);
$bot = new Bot('telegramToken');
$bot->sendMessage($sendMessage);
```CallbackQuery:
```php
getMessage()->getChat()->getId(), 'Click on inline button.');
$sendMessage->setReplyMarkup($keyboard);
$bot = new Bot('telegramToken');
$bot->sendMessage($sendMessage);
```## AnswerCallbackQuery
```php
getCallbackQuery()) {
$bot = new Bot('telegramToken');
$bot->answerCallbackQuery(new AnswerCallbackQuery($callbackQuery->getId()));
}
```## Developed by Forma-Pro
Forma-Pro is a full stack development company which interests also spread to open source development.
Being a team of strong professionals we have an aim an ability to help community by developing cutting edge solutions in the areas of e-commerce, docker & microservice oriented architecture where we have accumulated a huge many-years experience.
Our main specialization is Symfony framework based solution, but we are always looking to the technologies that allow us to do our job the best way. We are committed to creating solutions that revolutionize the way how things are developed in aspects of architecture & scalability.If you have any questions and inquires about our open source development, this product particularly or any other matter feel free to contact at [email protected]
## License
It is released under the [MIT License](LICENSE).