1. Go to this page and download the library: Download fizzday/fizzjwt 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/ */
fizzday / fizzjwt example snippets
use Fizzday\FizzJWT\FizzJWT;
$key = "example_key";
$payload = array(
"iss" => "http://fizzday.net",
"aud" => "http://fizzday.net",
"iat" => time(),
"exp" => time() + 60,
"nbf" => time() + 0,
"name" => "fizzday",
"age" => 26,
"sex" => "MALE"
);
/**
* IMPORTANT:
* You must specify supported algorithms for your application. See
* https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
* for a list of spec-compliant algorithms.
*/
$token = FizzJWT::encode($payload, $key);
$decoded = FizzJWT::decode($token, $key);
print_r($decoded);
/*
NOTE: This will now be an object instead of an associative array. To get
an associative array, you will need to cast it as such:
*/
$decoded_array = (array) $decoded;
/**
* You can add a leeway to account for when there is a clock skew times between
* the signing and verifying servers. It is recommended that this leeway should
* not be bigger than a few minutes.
*
* Source: http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#nbfDef
*/
// $leeway in seconds, 多延时60秒token才生效,在nbf设定的基础上累加
FizzJWT::$leeway = 60;
$decoded = FizzJWT::decode($token, $key);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.