PHP code example of chipslays / tas-wrapper

1. Go to this page and download the library: Download chipslays/tas-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chipslays / tas-wrapper example snippets


use TelegramApiServer\Client;

ost' => '127.0.0.1',
    'port' => '9503',
    'session' => 'session_name',
]);

$response = $client->get('getSelf')->execute(); // GET request
$response = $client->post('getSelf')->execute(); // POST request

$response = $client->get('messages.sendMessage', [
    'peer' => '@chipslays',
    'message' => 'Hello from tas-wrapper! 👋',
    'parse_mode' => 'html',
])->execute();

$response = $client
                ->get('getSelf')
                ->option(CURLOPT_TIMEOUT, 60)
                ->option(CURLOPT_HEADER, false)
                ->execute();

$client->map('sendMessage', fn($peer, $text) => $client->get('messages.sendMessage', [
    'peer' => $peer,
    'message' => $text,
])->execute());

$response = $client->sendMessage('@chipslays', 'so simple!');

$client->mapOnce('getSelf', fn() => $client->get('getSelf')->execute());

$me = $client->getSelf();

use TelegramApiServer\Session;

config
// NOTE: If you have the same data, you can skip this
Session::setConfig([
    'host' => '127.0.0.1',
    'port' => '9503',
    'schema' => 'http',
]);

// Get sessions list
$response = Session::list();

// Adding new session
$response = Session::add('session_name');

// Removing session (session file will remain)
$response = Session::remove('session_name');

// Remove session file
// WARNING: Don`t forget to logout and call `removeSession` first!
$response = Session::unlink('session_name');