Web page licensing access to user basic information

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.