登錄網站:https://packagist.org/,搜索jwt
使用:
1.引入:
use \Firebase\JWT\JWT;
2.使用
$key = 'api';
$payload = array(
// "iss" => "http://example.org",
// "aud" => "http://example.com",
"iat" => time(),//簽發時間
"nbf" => time(),//有效時間
'exp'=>time() + 60 * 60 / 2,//過期時間
'uid'=>$info['id'] //用戶信息
);
$token = JWT::encode($payload, $key);
具體參考上面搜索出來的文檔