一.安装
通过 composer 安装
运行以下命令进入JWT:
composer require firebase/php-jwt 5.3.0
创建server层:
<?php
namespace app\common;
use Firebase\JWT\JWT as CreateJwt;
class JWT
{
public static function signToken($openid)
{
$key = '15553242780';
$token = array(
"iss"=>$key,
"aud"=>'',
"iat"=>time(),
"nbf"=>time()+3,
"exp"=>time()+200,
"data"=>[
'uid'=>$openid,
]
);
$jwt = CreateJwt::encode($token,$key,"HS256");
return $jwt;
}
public static function checkToken($token)
{
$key = '15553242780';
$status = array("