Telegram Bot API Client
PHP
Latest commit 166cb9e Aug 25, 2016 @zelenin bugfix
Permalink
Failed to load latest commit information.
Client Types refactoring Apr 12, 2016
Daemon remove amp dependency. naive daemon Apr 12, 2016
Exception remove TypeInterface Apr 12, 2016
Type bugfix Aug 25, 2016
Api.php add group admistrator tools Aug 25, 2016
ApiFactory.php Client refactoring Apr 12, 2016
LICENSE init Jun 27, 2015
composer.json remove amp dependency. naive daemon Apr 12, 2016
readme.md readme fix Apr 13, 2016

readme.md

Telegram Bot API Client

Telegram Bot API Client.

Installation

Composer

The preferred way to install this extension is through Composer.

Either run

php composer.phar require "zelenin/telegram-bot-api" "~1.0"

or add

"zelenin/telegram-bot-api": "~1.0"

to the require section of your composer.json

Usage

$api = ApiFactory::create($token);

try {
    $response = $api->sendMessage([
        'chat_id' => $chatId,
        'text' => 'Test message'
    ]);
    print_r($response);

    $response = $api->sendPhoto([
        'chat_id' => $myId,
        'photo' => fopen('/home/www/photo.jpg', 'r')
    ]);
    print_r($response);
} catch (\Zelenin\Telegram\Bot\Exception\NotOkException $e) {
    echo $e->getMessage();
}

See Bot API documentation for other methods.

Daemon

$api = ApiFactory::create($token);

$daemon = new \Zelenin\Telegram\Bot\Daemon\NaiveDaemon($api);

$daemon
    ->onUpdate(function (\Zelenin\Telegram\Bot\Type\Update $update) {
        print_r($update);
    });

$daemon->run();

Author

Aleksandr Zelenin, e-mail: aleksandr@zelenin.me