PHPackages                             alexvkokin/telegram-mini-app-validation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. alexvkokin/telegram-mini-app-validation

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

alexvkokin/telegram-mini-app-validation
=======================================

Validating InitData received via the Mini App

1.0.0(1y ago)33.1k↓30%PHPPHP ^8.2

Since Jan 27Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/alexvkokin/telegram-mini-app-validation)[ Packagist](https://packagist.org/packages/alexvkokin/telegram-mini-app-validation)[ RSS](/packages/alexvkokin-telegram-mini-app-validation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

PHP Library for Validating Telegram Mini App Users
==================================================

[](#php-library-for-validating-telegram-mini-app-users)

This PHP library provides functionality for validating users of Telegram Mini Apps based on the `initData` string sent to the backend by the Telegram Web App. The validation process ensures the integrity of the received data using Telegram's guidelines.

Installation
------------

[](#installation)

To install the library, use Composer:

```
composer require alexvkokin/telegram-mini-app-validation
```

How It Works
------------

[](#how-it-works)

The library performs the following steps:

1. **Parse and decode the `initData` string** received in the request.
2. **Validate the hash** using the bot token and the received data.
3. **Resolve the user data** into a structured `WebAppUser` object if the validation is successful.

Code Example
------------

[](#code-example)

### Backend Implementation

[](#backend-implementation)

Here's how you can use the library in your backend application:

```
