vlsv/telegram-data-validator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

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

workflow

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

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2024-01-13