Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need try catch $result = $app->auth->session($code); #15

Open
okami-chen opened this issue Jun 15, 2020 · 1 comment
Open

need try catch $result = $app->auth->session($code); #15

okami-chen opened this issue Jun 15, 2020 · 1 comment

Comments

@okami-chen
Copy link

namespace Hanson\LaravelAdminWechat\Services;


use Illuminate\Support\Facades\Cache;

class MiniService
{
    /**
     * 通过 code 获取 session 信息
     *
     * @param string $appId
     * @param string $code
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     */
    public function session(string $appId, string $code)
    {
        $app = \Hanson\LaravelAdminWechat\Facades\ConfigService::getInstanceByAppId($appId);

        
        $result = $app->auth->session($code);

        Cache::forever($this->getSessionKey($result['openid']), $result['session_key']);

        return $result;
    }
@Hanson
Copy link
Owner

Hanson commented Jun 15, 2020

不捕捉的原因是因为这里一般都是因为配置错误导致的,可以把你的错误复制出来

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants