WxPublic.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\common\library;
  3. use EasyWeChat\Factory;
  4. use fast\Random;
  5. use think\Hook;
  6. /**
  7. * 短信验证码类
  8. */
  9. class WxPublic
  10. {
  11. /** @var \EasyWeChat\OfficialAccount\Application $app */
  12. protected $app;
  13. /**
  14. * WxpLogin constructor.
  15. */
  16. public function __construct()
  17. {
  18. $this->app=Factory::officialAccount([
  19. 'app_id'=>config('site.wx_open_appid'),
  20. 'secret'=>config('site.wx_open_secret'),
  21. 'log' => [
  22. 'level' => 'debug',
  23. 'file' => RUNTIME_PATH.'/wxp/wechat.log',
  24. ],
  25. 'oauth' => [
  26. 'scopes' => ['snsapi_base'],
  27. 'callback' => '/index/user/wxp_handle',
  28. ],
  29. ]);
  30. }
  31. /**
  32. * @return \EasyWeChat\OfficialAccount\Application
  33. */
  34. public function getApp()
  35. {
  36. return $this->app;
  37. }
  38. public function qr(){
  39. return $this->getApp()
  40. ->qrcode
  41. ->temporary(session_create_id(),3600);
  42. }
  43. }