Client.php 977 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * This file is part of the overtrue/wechat.
  4. *
  5. * (c) overtrue <i@overtrue.me>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace EasyWeChat\MiniProgram\Auth;
  11. use EasyWeChat\Kernel\BaseClient;
  12. /**
  13. * Class Auth.
  14. *
  15. * @author mingyoung <mingyoungcheung@gmail.com>
  16. */
  17. class Client extends BaseClient
  18. {
  19. /**
  20. * Get session info by code.
  21. *
  22. * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
  23. *
  24. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  25. */
  26. public function session(string $code)
  27. {
  28. $params = [
  29. 'appid' => $this->app['config']['app_id'],
  30. 'secret' => $this->app['config']['secret'],
  31. 'js_code' => $code,
  32. 'grant_type' => 'authorization_code',
  33. ];
  34. return $this->httpGet('sns/jscode2session', $params);
  35. }
  36. }