shaygan/telegram-bot-api-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shaygan/telegram-bot-api-bundle

Composer 安装命令:

composer require shaygan/telegram-bot-api-bundle

包简介

A simple wrapper for telegram-bot-api.

README 文档

README

A symfony wrapper bundle for Telegram Bot API with some tiny feature.

Install

Via Composer

$ composer require shaygan/telegram-bot-api-bundle @dev

Edit your app/AppKernel.php to register the bundle in the registerBundles() method as above:

class AppKernel extends Kernel
{

    public function registerBundles()
    {
        $bundles = array(
            // ...
            // register the bundle here
            new \Shaygan\TelegramBotApiBundle\ShayganTelegramBotApiBundle()
        );
    }
}

Configure the bundle

This bundle was designed to just work out of the box. The only thing you have to configure in order to get this bundle up and running is your bot token.

# app/config/config.yml

shaygan_telegram_bot_api:
    token: xxxxx:yyyyyyyyyyyyyyyyyyyy

If you want to use web-hook, add the bundle's routing configuration in app/config/routing.yml :

shaygan_telegram_bot_api:
    resource: @ShayganTelegramBotApiBundle/Resources/config/routing.yml

And add your domain name, url prefix (if needed) and you update receiver service name (a sample update receiver is included) to the configuration file:

# app/config/config.yml

shaygan_telegram_bot_api:
    #...
    webhook:
        domain: example.com
        path_prefix: ~ # you can add prefix, if your web site is not on the root
        update_receiver: shaygan.my_update_receiver # sample update receiver

note: Telegram do not support http, your site should have valid SSL (HTTPS).

Usage

Wherever you have access to the service container :

<?php
    // get the telegram api as a service
    $api = $this->container->get('shaygan.telegram_bot_api');

    // test the API by calling getMe method
    $user = $api->getMe();

?>

Next...

Please refer to Telegram Bot API Official Document for getting infomration about available methods and other informations:

Troubleshooting

If you did all the configurations correctly but still getting errors (Http error 500) even on getMe method, it might be because of SSL Verification. Please make sure you have up-to-date CA root certificate bundle to be used with cURL.

You can configure you CA root certificate bundle by:

  1. Downloading up-to-date cacert.pem file from cURL website and
  2. Setting a path to it in your php.ini file, e.g. on Windows:

curl.cainfo=c:\php\cacert.pem

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 5.11k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 24
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 23
  • Watchers: 2
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-19