<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                下載地址 ``` composer require firebase/php-jwt ``` ___ ``` <?php namespace app\index\controller; use \Firebase\JWT\JWT; class Jwts { private static $config = [ 'key'=>'thisisakey', 'iss' => 'http://free.cn', //簽發者 可選 'aud' => 'http://free.cn', //接收該JWT的一方,可選 'exp' => 7200, //過期時間,這里設置2個小時 ]; /** * @param $user_id * @return string */ public static function getToken($user_id){ $time = time(); //當前時間 $token = [ 'iss' => self::$config['iss'], //簽發者 可選 'aud' => self::$config['aud'], //接收該JWT的一方,可選 'iat' => $time, //簽發時間 'nbf' => $time-1 , //(Not Before):某個時間點后才能訪問,比如設置time+30,表示當前時間30秒后才能使用 'exp' => $time+self::$config['exp'], //過期時間,這里設置2個小時 'data' => [ //自定義信息,不要定義敏感信息 'userid' =>$user_id, ] ]; return JWT::encode($token, self::$config['key']); //輸出Token 默認'HS256' } /** * @param $token */ public static function verifyToken($token){ try { JWT::$leeway = 60;//當前時間減去60,把時間留點余地 $decoded = JWT::decode($token, self::$config['key'], ['HS256']); //HS256方式,這里要和簽發的時候對應 return (array)$decoded; } catch(\Firebase\JWT\SignatureInvalidException $e) { //簽名不正確 return json(['code'=>403,'msg'=>'簽名錯誤']); }catch(\Firebase\JWT\BeforeValidException $e) { // 簽名在某個時間點之后才能用 return json(['code'=>401,'msg'=>'token失效']); }catch(\Firebase\JWT\ExpiredException $e) { // token過期 return json(['code'=>401,'msg'=>'token已過期']); }catch(Exception $e) { //其他錯誤 return json(['code'=>404,'msg'=>'非法請求']); }catch(\UnexpectedValueException $e) { //其他錯誤 return json(['code'=>404,'msg'=>'非法請求']); } catch(\DomainException $e) { //其他錯誤 return json(['code'=>404,'msg'=>'非法請求']); } } } ``` ``` ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看