micromagicman / laravel-telegram-webapp
Laravel middleware for Telegram WebApp data validation
v2.0.0
2024-04-08 17:11 UTC
Requires
- php: >=8.2
- illuminate/routing: ^11.0
- illuminate/support: ^11.0
Requires (Dev)
- ext-dom: *
- nunomaduro/collision: ^8.0
- orchestra/testbench: ^9.0.0
- phpunit/php-code-coverage: ^11.0.0
- phpunit/phpunit: 11.0.10
This package is auto-updated.
Last update: 2024-04-15 03:54:33 UTC
README
Laravel package that allows you to process commands from Telegram MiniApp with user verification according to Telegram MiniApp developer documentation, as well as obtaining information about the Telegram user who sent the request
Requirements
Laravel | micromagicman/laravel-telegram-webapp |
---|---|
10.x | 1.x.x |
11.x | 2.x.x |
Install
Via composer
composer require micromagicman/laravel-telegram-webapp
Publishing
Publish to your Laravel application:
php artisan vendor:publish --provider="Micromagicman\TelegramWebApp\TelegramWebAppServiceProvider"
Configure
All package configuration available in config/telegram-webapp.php
file after publish
command execution:
Config name | Description | Environment | Default value |
---|---|---|---|
enabled |
Telegram MiniApp data validation switch | TELEGRAM_WEBAPP_DATA_VALIDATION_ENABLED |
true |
webAppScriptLocation |
Path to script (.js) which initializes Telegram MiniApp on your frontend app | - | https://telegram.org/js/telegram-web-app.js |
botToken |
Your Telegram bot token | TELEGRAM_BOT_TOKEN |
- |
error.status |
HTTP status code when Telegram MiniApp data validation fails | - | 403 (Forbidden) |
error.message |
HTTP status code when Telegram MiniApp data validation fails | - | 403 (Forbidden) |
Example in code:
View
This package provides a root view for Telegram MiniApp frontend applications.
Telegram WebApp script is automatically includes to this view or its
inheritors if telegram-webapp.enabled
switch is true
Example:
@extends('telegram-webapp::main') @section('lang', 'CN') @section('head') // some scripts, css, meta @endsection @section('title', 'My title') @section('content') <div id="app-content"> // My spa content </div> @endsection