Token.php 600 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * Author: luzheng.liu
  4. * Time: 2020/8/26 14:50
  5. */
  6. namespace app\index\controller;
  7. use app\index\BaseController;
  8. use app\index\exception\ApiException;
  9. use app\common\until\Until;
  10. use Firebase\JWT\JWT;
  11. class Token {
  12. public function getToken($userId = '') {
  13. if (empty($userId)){
  14. $id = input('visitor') ?: random_int(100000,999999);
  15. }else{
  16. $id = $userId;
  17. }
  18. $tokenService = new \app\common\until\Token();
  19. $token = $tokenService->getToken($id,uniqid('visitor',false));
  20. Until::output(['token' => $token]);
  21. }
  22. }