Auth.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | auth.php 用于做权限验证
  5. |--------------------------------------------------------------------------
  6. */
  7. namespace Service\Src;
  8. use Dever;
  9. use Main\Lib\Wechat;
  10. class Auth
  11. {
  12. /**
  13. * wechat
  14. *
  15. * @var Wechat
  16. */
  17. private $wechat;
  18. /**
  19. * result
  20. *
  21. * @var array
  22. */
  23. private $result;
  24. /**
  25. * output
  26. *
  27. * @var string
  28. */
  29. private $output;
  30. /**
  31. * 构造函数 初始化
  32. *
  33. * @return mixed
  34. */
  35. public function __construct()
  36. {
  37. $this->wechat = new Wechat(false, 'service');
  38. }
  39. /**
  40. * 获取签名数据,主要用于jssdk
  41. *
  42. * @return mixed
  43. */
  44. public function sign()
  45. {
  46. $url = Dever::input('url');
  47. return $this->wechat->sign($url);
  48. }
  49. /**
  50. * 获取ticket
  51. *
  52. * @return mixed
  53. */
  54. public function ticket()
  55. {
  56. return $this->wechat->ticket(false, false, 2000, true);
  57. }
  58. /**
  59. * 获取token 一般为系统token
  60. *
  61. * @return mixed
  62. */
  63. public function token()
  64. {
  65. return $this->wechat->token(false, false, 2000, true);
  66. }
  67. }