PHP library for handling authorise request from AuthGramBot
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
composer.json

README.md

AuthGram authorise request handler

Overview

This is library for handling authorise request of AuthGramBot. It get raw body of POST request, parse and transform to PHP object which is ready for use in your project.

Installation

The recommended way to install the SDK is with Composer. Composer is a dependency management tool for PHP that allows you to declare the dependencies your project needs and installs them into your project.

composer require devbackend/authgram-request-handler

If composer install globally in your system, you can run next command:

composer require devbackend/authgram-request-handler

Alternatively, you can specify the SDK as a dependency in your project's existing composer.json file:

{
    "require" : {
        "devbackend/authgram-request-handler": "^2.0" 
    }
}

After installing, you need to require Composer's autoloader:

require vendor/autoload.php;

And create instance of request handler by passing to it constructor your application token:

$requestHandler = new Devbackend\AuthGramRequestHandler\AuthGramRequestHandler('[APPLICATION_TOKEN]');

if ($requestHandler->isValidToken()) {
    $request = $requestHandler->getRequest();

    $authKey  = $request->getAuthKey();
    $user     = $request->getUser();    
    $username = $user->getUsername();
}