kukymbr/telegramer

Utility to work with telegram bot API methods

v0.1.2 2019-11-20 09:15 UTC

This package is not auto-updated.

Last update: 2024-10-03 08:48:34 UTC


README

Package to access Telegram Bot API from the php.

Requirements

Telegramer requires PHP 7.0+.

Installation

The supported way of installing Telegramer is via Composer.

$ composer require kukymbr/telegramer

Usage

<?php

use \Kukymbr\Telegramer\Connection;
use \Kukymbr\Telegramer\Bot;
use \Kukymbr\Telegramer\Response;
use \Kukymbr\Telegramer\Notifier;

$connection = new Connection();
// You can set your cURL options here.
// For example, proxy settings.
$connection->setOptArray([]);

$bot = new Bot('12345:YourBotToken', $connection);

// Send a request to API method via magic
$me = $bot->getMe();

/**
 * @var Response $me
 */
if ($me->isOk()) {
    // Do something with the result 
    var_dump($me->result());
}

$notifier = new Notifier($bot);
$notifier->addChat(123456);

$notifier->send('Some message from the site');
$notifier->sendMap(
    [
        'New request #123',
        'name' => 'John',
        'phone' => '+123456789'
    ],
    [
        'name' => 'User name',
        'phone' => 'User phone'    
    ]
);

License

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