微信网页授权获取用户基本信息
来源:互联网 发布:network connect mac 编辑:程序博客网 时间:2024/05/22 06:58
首先引导用户去授权页面:
地址:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appid&redirect_uri=redirect_uri&response_type=code&scope=SCOPE&state=STATE#wechat_redirect";
用户同意授权后,页面将跳转至 redirect_uri/?code=CODE&state=STATE
//通过code换取token$code = $_GET['code'];$url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=appid&secret=SECRET&code=$code&grant_type=authorization_code";$json = file_get_contents($url);$arr = json_decode($json,true);$token = $arr['access_token'];$openid = $arr['openid'];//拿到token后就可以获取用户基本信息了$url = "https://api.weixin.qq.com/sns/userinfo?access_token=$token&openid=$openid ";$json = file_get_contents($url);//获取微信用户基本信息$arr = json_decode($json,true);$name = $arr['nickname'];//昵称$imgURL = $arr['headimgurl'];//头像地址$sex = $arr['sex'];//性别$province = $arr['province'];//用户个人资料填写的省份$city= $arr['city'];//普通用户个人资料填写的城市$country= $arr['country'];//国家,如中国为CN
0 0
- 微信网页授权获取用户基本信息
- 微信网页授权获取用户基本信息
- 微信网页授权获取用户基本信息
- 微信网页授权获取用户基本信息
- 微信网页授权获取用户基本信息
- Java微信网页授权授权获取用户基本信息
- 微信公众平台开发 网页授权获取用户基本信息
- 微信公众平台开发 网页授权获取用户基本信息
- 微信公众平台开发-网页授权获取用户基本信息
- 微信平台网页授权获取用户基本信息
- 微信oauth网页授权获取用户基本信息
- 微信使用网页授权获取用户基本信息
- 微信公众号网页授权获取用户基本信息
- 微信 网页授权获取用户基本信息 (一)
- 微信开发--网页授权获取用户基本信息
- flask 微信公众号 网页授权获取用户基本信息
- 微信网页授权获取用户基本信息--PHP
- 微信开发-网页授权获取用户基本信息
- /bin和/sbin 用法详解
- Windows下安装设置Atlassian-Confluence-5.1.4并破解汉化(另附图解)
- pb数据格式,pb协议->pb解析库
- 并发编程之Operation Queue和GCD
- ios 工具
- 微信网页授权获取用户基本信息
- random selection
- 位图(BitMap)索引
- Linux系统各个目录的作用(中英文对照)
- Weka J48决策树算法(C4.5)源码学习
- Python 学习入门—— 正则表达式 转载
- linux下mnt目录作用
- 17周项目五(换钱币)
- 【转载】logistic regression C++实现