Client.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 App\Libs\TikTok\MiniProgram\Auth;
  11. use App\Libs\TikTok\Kernel\BaseClient;
  12. use App\Libs\TikTok\Kernel\Exceptions\HttpException;
  13. use App\Libs\TikTok\Kernel\Exceptions\InvalidConfigException;
  14. use GuzzleHttp\Exception\GuzzleException;
  15. /**
  16. * Class Auth.
  17. *
  18. * @author mingyoung <mingyoungcheung@gmail.com>
  19. */
  20. class Client extends BaseClient {
  21. protected $needAccessToken = false;
  22. /**
  23. * Get session info by code.
  24. * @param string $code
  25. * @param string $anonymousCode
  26. * @return array
  27. * @throws GuzzleException
  28. * @throws HttpException
  29. * @throws InvalidConfigException
  30. */
  31. public function session(string $code, string $anonymousCode = ''): array {
  32. $params = [
  33. 'appid' => $this->app['config']['app_id'],
  34. 'secret' => $this->app['config']['secret'],
  35. 'code' => $code,
  36. 'anonymous_code' => $anonymousCode
  37. ];
  38. return $this->httpPostJson('apps/v2/jscode2session', $params);
  39. }
  40. }