PHP code example of picios / tokenizer

1. Go to this page and download the library: Download picios/tokenizer 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/ */

    

picios / tokenizer example snippets

 php


use Picios\Tokenizer\TokenManager;

information about fields, that the token will contain. In this case only 'id'
]);
$token = $tm->createToken([
    'id' => 5,
]);
// call token __toString() function
echo "{$token}";
 php


use Picios\Tokenizer\TokenManager;
use Picios\Tokenizer\TokenNotValidException;

l contain. In this case only 'id'
]);

// incoming token  e.g. from the Request::query object
// or just $_GET array
$stringToken = 'NDc5NWI4MjAxOS0wOC0wNlQwODozNjoxMCswMjowMHsiaWQiOjV9';

try {
    $token = $tm->parse($stringToken);
    echo "This is a secret content taken by token id {$token->get('id')}";
} catch (TokenNotValidException $e) {
    echo "Invalid token";
    exit();
}