Code Monkey home page Code Monkey logo

laravel-telegram-webapp's Introduction

Laravel Telegram WebApp package

build codecov

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 Error message returned when Telegram MiniApp data validation fails - 403 (Forbidden)
authDateLifetimeSeconds The lifetime of the Telegram initData auth_date parameter in seconds. The request to the server must be made within this interval, otherwise the data transmitted from Telegram will be considered invalid. The values of the parameter <= 0 imply that there is no verification of the lifetime of data from telegram and the auth_date parameter is not validated - 0

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

Telegram bot API

answerWebAppQuery

Set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, an Illuminate\Http\Client\Response object is returned.

Parameters

$result - one of InlineQueryResult variations (php array)

use Micromagicman\TelegramWebApp\Api\TelegramBotApi;

private TelegramBotApi $botApi;

$response = $botApi->answerWebpAppQuery([
    'type' => 'document'
    // ...
    // one of InlineQueryResult variations
    // ...
]);

laravel-telegram-webapp's People

Contributors

micromagicman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

laravel-telegram-webapp's Issues

Provide more examples

Could you provide more examples of how to use this package? A starter boiler plate example for beginners would be helpful!

Laravel 11 Support

Thank you for making this package! I'm interested in integrating this package into my Laravel app. However composer is complaining when using it with Laravel 11.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.