# 类名
~~~
\Oreo\Wechat\Auth\WechatAuth
~~~
#
# 参数
| 名称 | 类型 | 说明 |
| --- | --- | --- |
| appId | String | 公众号的唯一标识 |
| appSecret | String | 公众号的SecretKey |
| code | String | 用户Code(上一步骤获取的用户Code) |
#
## 调用函数
| 函数名称 | 类型 | 传参值 |说明 |
| --- | --- | --- |--- |
| authIndex | Int | 2 | 1=>获取Code; 2=>Code兑换OpenId和access_token;3=>小程序Code兑换OpenId;4=>根据access_token和OpenId获取用户信息;|
#
## 调用方法(实例)
```
$wx = new \Oreo\Wechat\Auth\WechatAuth(); //初始化类
$wx->appId = 'wxc123457898'; //公众号appId
$wx->appSecret = '05c139ee3123456789abcdef'; //公众号appSecret
$wx->code = $_GET['code']; //第一步获取的code参数
$res = $wx->authIndex(2);
/*
var_dump($res);
exit();
*/
//将会获取到
//$access_token = $res['access_token']; //用户access_token
//$openid = $res['openid']; //用户openId
```