NodeJS如何发送HTTPS请求
来源:互联网 发布:手机防锁机软件 编辑:程序博客网 时间:2024/05/14 20:02
http://blog.csdn.net/baby97/article/details/49702379
微信的接口都使用HTTPS协议,使用NodeJS需创建HTTPS对象.
详细使用参考官网文档https://nodejs.org/api/https.html
代码如下:
- var https = require("https");
- var iconv = require("iconv-lite");
- var url="https://api.weixin.qq.com/sns/oauth2/access_token?appid="+appid+"&secret="+secret+"&code="+code+"&grant_type=authorization_code";
- https.get(url, function (res) {
- var datas = [];
- var size = 0;
- res.on('data', function (data) {
- datas.push(data);
- size += data.length;
- //process.stdout.write(data);
- });
- res.on("end", function () {
- var buff = Buffer.concat(datas, size);
- var result = iconv.decode(buff, "utf8");//转码//var result = buff.toString();//不需要转编码,直接tostring
- console.log(result);
- });
- }).on("error", function (err) {
- Logger.error(err.stack)
- callback.apply(null);
- });
阅读全文
0 0
- NodeJS如何发送HTTPS请求
- NodeJS如何发送HTTPS请求
- nodejs http 发送请求
- nodejs http 发送请求
- nodejs发送post请求
- Qt 发送 https 请求
- java 发送 https请求
- Qt 发送 https 请求 .
- java发送https请求
- HTTPClient 发送HTTPS请求
- https发送post请求
- java 发送HTTPS请求
- 使用Https发送请求
- httpClient发送https请求
- esp8266发送https请求
- jmeter发送HTTPS请求
- Java---发送HTTPS请求
- ruby发送http,https请求
- 34岁!100天!学会Java编程(Day12)——知识点串连
- android实现选中变大变小效果及边框效果的方式
- MySQL存储过程遍历游标用loop嵌套循环的例子
- Linux 内存与I/O访问
- 91. Decode Ways 解码方法
- NodeJS如何发送HTTPS请求
- [备忘录]-Ubuntu下安装JDK的几种方式
- 解决 id_rsa 权限不够
- Redis命令的请求和执行过程
- 机器学习理论与实战(十一)关联规则分析Apriori .
- pandas的应用
- Python
- QT之qss教程-QLineEdit
- ECMAScript 2015(ES6):import和export命令