| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- /*
- * This file is part of the overtrue/wechat.
- *
- * (c) overtrue <i@overtrue.me>
- *
- * 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 <mingyoungcheung@gmail.com>
- */
- 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);
- }
- }
|