Authorized login.
Basic situation: Certified service number;
Main test code:
Publicfunction Openoauth () {//gets the code in the callback connection$code = $_get['Code']; //Get Access_token OpenID$json = file_get_contents ("https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx7a5423a6f023716c5&secret= 6bb7bstddekxrsa3bdcd296979bfb66967f41&code= $code &grant_type=authorization_code"); $json=Json_decode ($json); $refresh _token= $jsonRefresh_token;
Get the Access_token $json you need through Refresh_token _ref= File_get_contents ("Https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=wx3a542a6f094310c5&grant_type=refresh_token &refresh_token= $refresh _token"); $json _ref=Json_decode ($json _ref); $access _token= $json _ref->Access_token; $openId= $json _ref->OpenID; $json _userinfo= File_get_contents ("https://api.weixin.qq.com/sns/userinfo?access_token= $access _token&openid= $openId &lang=zh_cn"); $json _userinfo=Json_decode ($json _userinfo); $nikename= $json _userinfo->nickname; $sex= $json _userinfo->sex; $area= $json _userinfo->province.'-'. $json _userinfo->city.'-'. $json _userinfo->Country; $headimgurl= $json _userinfo->Headimgurl; //echo $headimgurl;$privilege = $json _userinfo->privilege; $unionid= $json _userinfo->Unionid; Echo""; Echo""; Echo""; Echo""; Echo''. $headimgurl.'">'; Echo""; Echo""; }
Personal complete document; Http://files.cnblogs.com/bin-pureLife/%E5%B0%8F%E5%9B%BE%E6%A0%87.zip
APPID and other privacy.
Web page licensing access to user basic information