PHP code example of bayfrontmedia / php-jwt
1. Go to this page and download the library: Download bayfrontmedia/php-jwt 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/ */
bayfrontmedia / php-jwt example snippets
composer
$header = [
'cty' => 'custom-content-type;v=1'
];
$jwt->setHeader($header);
$payload = [
'user_id' => 10
];
$jwt->setPayload($payload);
$now = time();
$token = $jwt->iss('API key whose secret signs the token')
->iat($now)
->nbf($now)
->exp($now + 86400) // 24 hours
->encode([
'user_id' => 10
]);