定制 chipslays/tas-wrapper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

chipslays/tas-wrapper

Composer 安装命令:

composer require chipslays/tas-wrapper

包简介

Simple API wrapper for easy manage TelegramApiServer.

README 文档

README

Simple API wrapper for easy manage TelegramApiServer in your project.

Install

composer require chipslays/tas-wrapper

Example

Client

All methods from MadelineProto supported, methods list here.

use TelegramApiServer\Client;

require 'vendor/autoload.php';

$client = new Client([
    'host' => '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();

Also, you can define curl option by option(NAME_OPTION, 'value') method.

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

Map your own methods (aliases), it so simple:

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

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

Each time the sendMessage method is called, the function from the second parameter will be executed again.

If you need the function to work only once, and then return only the result of execution in subsequent times, use the mapOnce() method instead of map().

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

$me = $client->getSelf();

Session

Manage TelegramApiServer session, more detail here.

use TelegramApiServer\Session;

require 'vendor/autoload.php';

// This is example of default 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');

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固