Source code of Ecshop third-party authorization QR code logon interface file
[PHP] code
'Text', 'name' => 'app _ key', 'value' => ''), array ('type' => 'text ', 'name' => 'app _ secret', 'value' => ''),);} if (! Defined ('Website') {include_once (dirname (_ FILE __). '/oath2.class. php '); class website extends oath2 {function website () {$ this-> app_key = APP_KEY; $ this-> app_secret = APP_SECRET; $ this-> scope = 'snsapi _ login'; // by tiandi authorizeURL is used for PHP login, whereas authorizeURL is not used for JS calls. $ This-> authorizeURL =' https://open.weixin.qq.com/connect/qrconnect '; $ This-> tokenURL =' https://api.weixin.qq.com/sns/oauth2/access_token '; $ This-> refreshtokenURL =' https://api.weixin.qq.com/sns/oauth2/refresh_token '; $ This-> userURL =' https://api.weixin.qq.com/sns/userinfo '; $ This-> meth = 'get';} function Code2Token ($ code) {$ params = 'appid = '. $ this-> app_key. '& secret = '. $ this-> app_secret. '& code = '. $ code. '& grant_type = authorization_code'; $ tokenurl = $ this-> tokenURL. "? ". $ Params; $ token = $ this-> http ($ tokenurl, 'Get'); $ token = json_decode ($ token, true); return $ token ;} function GetRefreshToken ($ token) {$ params = 'appid = '. $ this-> app_key. '& grant_type = refresh_token & refresh_token = '. $ token; $ tokenurl = $ this-> refreshtokenURL. "? ". $ Params; $ token = $ this-> http ($ tokenurl, 'Get'); $ token = json_decode ($ token, true); return $ token ;} function Getinfo ($ token, $ openid) {$ params = 'Access _ token = '. $ token. '& openid = '. $ openid; $ userurl = $ this-> userURL. "? ". $ Params; $ userinfo = $ this-> http ($ userurl, 'Get'); return json_decode ($ userinfo, true );}}}