'获取第三方平台的token', 'method' => 'post', 'json' => true, 'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_component_token?', 'param' => array ( 'component_appid' => 'appid', 'component_appsecret' => 'secret', 'component_verify_ticket' => 'ticket', ), //针对一些返回的名称,做转换 'response' => array ( 'component_access_token' => 'token', //'expires_in' => 'expires_in', ), ); # oauth token $config['oauth'] = array ( //第一步,请求code 'code' => array ( 'name' => '获取oauth code', 'method' => 'post', 'json' => true, 'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?', 'param' => array ( 'component_access_token' => 'token', 'component_appid' => 'appid', ), 'response' => array ( 'pre_auth_code' => 'oauth.code', ), ), //第二步,拼装redirect,进行授权登录 'login' => array ( 'name' => '获取oauth login', 'method' => 'get', 'json' => false, 'url' => 'https://mp.weixin.qq.com/cgi-bin/componentloginpage?', 'param' => array ( 'component_appid' => 'appid', 'pre_auth_code' => 'code', 'redirect_uri' => 'redirect', 'auth_type' => '3', ), ), //第三步,获取到token 'oauth' => array ( 'name' => '获取oauth token', 'method' => 'post', 'json' => true, 'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_query_auth?', 'param' => array ( 'component_access_token' => 'token', 'component_appid' => 'appid', 'authorization_code' => 'auth_code', ), 'response' => array ( 'authorization_info.authorizer_appid' => 'openid', 'authorization_info.authorizer_appid.key' => 'unionid', 'authorization_info.authorizer_access_token' => 'oauth.oauth', 'authorization_info.authorizer_refresh_token' => 'refresh', 'authorization_info.expires_in' => 'expires_in', 'authorization_info.func_info' => 'callback.component/auth.saveOauthInfo',//定义回调 ), ), //第四步,根据refresh获取到token 'refresh' => array ( 'name' => '根据refresh获取oauth token', 'method' => 'post', 'json' => true, 'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?', 'param' => array ( 'component_access_token' => 'token', 'component_appid' => 'appid', 'authorizer_appid' => 'openid', 'authorizer_refresh_token' => 'refresh', ), 'response' => array ( 'authorizer_access_token' => 'oauth.refresh', 'authorizer_refresh_token' => 'refresh', ), ), ); # 获取用户信息 $config['user'] = array ( 'name' => '获取用户信息', 'method' => 'post', 'json' => true, 'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?', 'param' => array ( 'component_access_token' => 'token', 'component_appid' => 'appid', 'authorizer_appid' => 'openid', ), ); $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'component' . DIRECTORY_SEPARATOR; # 载入小程序接口配置 $config += include($path . 'applet.php'); return $config;