devbackend/authgram-request-handler

PHP library for handling authorise request from AuthGramBot

2.0.1 2017-12-12 11:45 UTC

This package is auto-updated.

Last update: 2024-05-28 19:40:53 UTC


README

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