nodejs微信开发--网页获取用户授权信息
来源:互联网 发布:剑灵捏脸数据免费的 编辑:程序博客网 时间:2024/06/12 20:12
思路是这样的,第一步在页面获取到授权以后的code
拿code去nodejs后台的httpserver请求
nodejs接到请求以后,拿到code去拿accessToken,然后通过accessToken获取用户信息
然后把用户信息扔给页面
后台nodejs代码:
var request = require('request');var nodeconfig = require('./nodeconfig');//api weixinfunction wx(res, postData) {console.log(getUrlVars(postData));//微信获取用户资料第二步通过code换取网页授权access_tokenrequest.get({url : 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx01ca1966fe6f8a88&secret=c893b05b38&'+postData+'&grant_type=authorization_code',form : {}}, function(error, response, body) {if (!error && response.statusCode == 200) {console.log(body);var jsondata = JSON.parse(body);//第四步拉取用户信息(需scope为 snsapi_userinfo)request.get({url : 'https://api.weixin.qq.com/sns/userinfo?access_token=' + jsondata.access_token + '&openid=' + jsondata.openid + '&lang=zh_CN',form : {}}, function(error, response, body) {if (!error && response.statusCode == 200) {var userdata = JSON.parse(body);console.log(userdata);nodeconfig.httpHeadSetting(res);res.end(JSON.stringify(userdata));}});}});}exports.wx = wx;
1 0
- nodejs微信开发--网页获取用户授权信息
- 微信公众号开发二:关于授权网页获取用户微信信息注册用户的开发
- 微信公众平台开发 网页授权获取用户基本信息
- 微信公众平台开发 网页授权获取用户基本信息
- 微信公众平台开发-网页授权获取用户基本信息
- 微信开发--网页授权获取用户基本信息
- 微信开发-网页授权获取用户基本信息
- 微信开发——网页授权获取用户基本信息
- 微信开发--网页授权获取用户基本信息
- 微信网页授权获取用户基本信息
- 微信网页授权获取用户基本信息
- 微信网页授权获取用户基本信息
- 微信网页授权获取用户基本信息
- 微信网页授权获取用户基本信息
- Java微信网页授权授权获取用户基本信息
- 微信开发-网页授权获取用户信息
- 微信公众号开发-微信网页授权获取用户openid以及用户信息的步骤
- 微信公众号开发-微信网页授权获取用户openid以及用户信息的步骤
- Android-Universal-Image-Loader三大组件DisplayImageOptions、ImageLoader、ImageLoaderConfiguration详解
- git初体验(四)git标签
- ToolBar的使用
- word 嵌入式图片不能显示,只显示一行。
- 根据IE和FF加载不同css样式文件
- nodejs微信开发--网页获取用户授权信息
- 断言(C++大师Andrei Alexandrescu的文章)[卸载microsoft visual c++ debug library]
- 一些题目iOS
- 64位linux centos 安装android问题及解决方案
- Linux下实现磁盘配额的两种方法
- Android基础入门教程——10.9 WallpaperManager(壁纸管理器)
- framebuffer小程序显示3个矩形 测试
- MapReduce计数器计数
- Notepad++找回自动保存缓存内容的文件