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

Update oauth.md #2790

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/src/5.x/official-account/oauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,11 @@ $config = [

$app = Factory::officialAccount($config);
$oauth = $app->oauth;

// 获取 OAuth 授权结果用户信息
$code = "微信回调URL携带的 code";
$user = $oauth->userFromCode($code);
// 不少用户这里的 code 是来源于静默授权 如果这里你的 $oauth 没有配置 scopes 为 snsapi_base 调用 $oauth->userFromCode($code); 默认会走 snsapi_userinfo;
$oauth = $app->oauth->scopes(['snsapi_base'])
$user = $oauth->userFromCode($code);

$_SESSION['wechat_user'] = $user->toArray();

Expand Down
Loading