PHP code example of vlsv / telegram-data-validator

1. Go to this page and download the library: Download vlsv/telegram-data-validator 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/ */

    

vlsv / telegram-data-validator example snippets


/**
 * 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 



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);