vlsv/telegram-data-validator
最新稳定版本:v1.0.4
Composer 安装命令:
composer require vlsv/telegram-data-validator
包简介
The Telegram Data Validator is a PHP library for validating the integrity of initData received from a Telegram mini-application. It uses HMAC-SHA-256 for data integrity checks.
README 文档
README
Telegram Data Validator
The Telegram Data Validator is a PHP library for validating the integrity of initData received from a Telegram mini-application. It uses HMAC-SHA-256 for data integrity checks.
Installation
Install the library using Composer:
composer require vlsv/telegram-data-validator
Documentation
/** * Validates the integrity of the provided Telegram WebApp initData string received from a Telegram * mini-application. * * @param string $initData The initData string containing query parameters. * @param string $botToken The bot token used for HMAC calculation. * @param bool $verbose Whether to include additional information in the result. * * @return bool|array If $verbose is true, returns an associative array with validation information, * otherwise returns a boolean indicating whether the validation passed. */ InitData::isValid(string $initData, string $botToken, bool $verbose = false): bool|array
Usage
<?php use Vlsv\TelegramInitDataValidator\Validator\InitData; // Your bot token $botToken = "<your-bot-token>"; // Your initData string $initData = "query_id=AAGk..."; // Validate initData $result = InitData::isValid($initData, $botToken, true); // Display the validation result var_dump($result);
Tests
composer tests
License
This project is licensed under the GNU General Public License v3.
统计信息
- 总下载量: 3.26k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2024-01-13