maxgorovenko / telegram-bot-api
Telegram Bot API 的包装器
dev-master
2016-05-29 21:41 UTC
Requires
- php: ^5.3.3 || ^7.0
- jms/serializer-bundle: ^1.1
This package is not auto-updated.
Last update: 2024-09-14 18:26:17 UTC
README
为与 Symfony 框架兼容的 Telegram Bot API 提供的包装器包。使用 JMS\Serializer 进行对象序列化和反序列化。
安装
通过 Composer
$ composer require maxgorovenko/telegram-bot-api-bundle @dev
对于 Symfony,您需要升级您的 AppKernel 和配置
# app/AppKernel.php class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... // register the bundle here new \MG\TelegramBotApiBundle\MGTelegramBotApiBundle() ); } }
# app/config/config.yml mg_telegram_bot_api: token: xxxxx:yyyyyyyyyyyyyyyyyyyy
用法
简单
查看 JMS Serializer 创建的 手册。
$botToken = '11111:2222222'; $serializer = JMS\Serializer\SerializerBuilder::create()->build(); $api = new MG\TelegramBotApiBundle\Service\Api($botToken, $serializer); $updates = $api->getUpdates();
与 symfony 一起使用
$api = $container->get('mg.telegram_bot_api'); $updates = $api->getUpdates();