mirror of
https://github.com/w7corp/easywechat.git
synced 2025-01-22 19:52:10 +00:00
补充API
parent
7103143c3d
commit
4bbaaf5a23
39
网页授权.md
39
网页授权.md
@ -80,5 +80,44 @@ $url = $auth->url('http://overtrue.me', 'snsapi_userinfo');
|
|||||||
$auth->user();
|
$auth->user();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
+ 获取授权信息
|
||||||
|
|
||||||
|
在每一次使用 code 得到 access_token 后,以下信息会存储:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"access_token":"ACCESS_TOKEN",
|
||||||
|
"expires_in":7200,
|
||||||
|
"refresh_token":"REFRESH_TOKEN",
|
||||||
|
"openid":"OPENID",
|
||||||
|
"scope":"SCOPE",
|
||||||
|
"unionid": "o6_bmasdasdsad6_2sgVt7hMZOPfL"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
你可以用以下方式获取,用来存储到你的数据库个人信息中
|
||||||
|
|
||||||
|
```php
|
||||||
|
$auth->access_token;// 获取本次授权后的 access_token
|
||||||
|
$auth->refresh_token;// 获取本次授权后的 refresh_token
|
||||||
|
// ...
|
||||||
|
```
|
||||||
|
|
||||||
|
+ 检查 access_token 是否有效
|
||||||
|
|
||||||
|
```php
|
||||||
|
$auth->accessTokenIsValid($accessToken, $openid); // 返回 boolean
|
||||||
|
```
|
||||||
|
|
||||||
|
+ 使用 refresh_token 刷新 access_token
|
||||||
|
|
||||||
|
```php
|
||||||
|
$auth->refresh($refreshToken); // 注意这里不是access_token
|
||||||
|
```
|
||||||
|
+ 使用 access_token 获取用户信息
|
||||||
|
|
||||||
|
```php
|
||||||
|
$auth->getUser($openId, $accessToken);
|
||||||
|
```
|
||||||
|
|
||||||
更多关于微信网页授权 API 请参考: http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html
|
更多关于微信网页授权 API 请参考: http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html
|
Loading…
Reference in New Issue
Block a user