Skip to content

Commit ca054f3

Browse files
committed
更新文档
1 parent 32e24be commit ca054f3

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,29 +129,28 @@ Route::group(['middleware' => ['easywechat.oauth:default,snsapi_userinfo']], fun
129129

130130
有时候我们希望在本地开发完成后线上才真实的走微信授权流程,这将减少我们的开发成本,那么你需要做以下两步:
131131

132-
1. 准备假资料:
133-
134-
> 以下字段在 scope 为 `snsapi_userinfo` 时尽可能配置齐全哦,当然,如果你的模式只是 `snsapi_base` 的话只需要 `openid` 就好了。
135-
132+
1. 准备模拟授权资料:
133+
2.
136134
```php
137135
use Illuminate\Support\Arr;
138136
use Overtrue\Socialite\User as SocialiteUser;
139137

140138
$user = new SocialiteUser([
141-
'id' => Arr::get($user, 'openid'),
142-
'name' => Arr::get($user, 'nickname'),
143-
'nickname' => Arr::get($user, 'nickname'),
144-
'avatar' => Arr::get($user, 'headimgurl'),
145-
'email' => null,
146-
'original' => [],
147-
'provider' => 'WeChat',
148-
]);
149-
139+
'id' => 'mock-openid',
140+
'name' => 'overtrue',
141+
'nickname' => 'overtrue',
142+
'avatar' => 'http://example.com/avatars/overtrue.png',
143+
'email' => null,
144+
'original' => [],
145+
'provider' => 'WeChat',
146+
]);
150147
```
151148

149+
> 以上字段在 scope 为 `snsapi_userinfo` 时尽可能配置齐全哦,当然,如果你的模式只是 `snsapi_base` 的话只需要 `openid` 就好了。
150+
152151
2. 将资料写入 session:
153152

154-
> 注意:一定要在 OAuth 中间件之前写入,比如你可以创建一个全局中间件来完成这件事儿,当然了,只在开发环境启用即可。
153+
> 注意:一定要在调用 OAuth 中间件之前写入,比如你可以创建一个全局中间件来完成这件事儿,只在开发环境启用即可。
155154
156155
```php
157156
session(['easywechat.oauth_user.default' => $user]); // 同理,`default` 可以更换为您对应的其它配置名

0 commit comments

Comments
 (0)