* * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace ByteDance\MiniProgram\Auth; use ByteDance\Kernel\BaseClient; /** * Class Auth. * * @author mingyoung */ class Client extends BaseClient { /** * Get session info by code. * * @param string $code * * @throws \ByteDance\Kernel\Exceptions\InvalidConfigException * * @return \Psr\Http\Message\ResponseInterface|\ByteDance\Kernel\Support\Collection|array|object|string */ public function session(string $code, bool $anonymous = false) { $params = [ 'appid' => $this->app['config']['app_id'], 'secret' => $this->app['config']['app_secret'], ]; if ($anonymous) { $params['anonymous_code'] = $code; } else { $params['code'] = $code; } return $this->httpGet('api/apps/jscode2session', $params); } }