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

拿到code=CODE&state=STATE之后怎么拿到openid? #452

Closed
sidgwick opened this issue Jul 11, 2016 · 1 comment
Closed

拿到code=CODE&state=STATE之后怎么拿到openid? #452

sidgwick opened this issue Jul 11, 2016 · 1 comment

Comments

@sidgwick
Copy link

sidgwick commented Jul 11, 2016

我用的环境

LNMP

PHP 版本:7.0.4
overtrue/wechat 版本:3.1.0

问题及现象

image

这里我拿到了codestate, 之后是怎么取到用户信息的? 按照文档, 在callback.php直接用$auth->user()会报The key "access_token" could not be empty.

我得callback模仿这里写的:
image

我是不是少了一步?

@sidgwick
Copy link
Author

额, 我懂了. $app->auth->user()的app的配置不能带oauth的配置?

原来的app, 这个取不到用户信息:

$this->app = new Application([
    'app_id' => self::APPID,
    'secret'  => self::APPSECRET,
    'debug'  => true,
    'oauth' => [
        'scopes'   => ['snsapi_userinfo'],
        'callback' => '/auth/weixin-openid',
    ],
]);

$this->app->oauth->user();

后来的app, 可以取到:

(new Application([
    'app_id' => self::APPID,
    'secret'  => self::APPSECRET,
    'debug'  => true,
]))->oauth->user();

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

1 participant