首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >微信接口使用 node.js通过代理发送https请求?

微信接口使用 node.js通过代理发送https请求?

提问于 2017-11-20 11:57:34
回答 2关注 0查看 879

由于微信的接口都使用https协议,现在需要在nodejs调微信的接口,即发送https请求。但总是报连接超时,应该是被公司内网屏蔽了。现在需要通过公司的代理发送出去,但是不知道怎么设置。在网上查了下发送http请求的代理设置,如下,求大神赐教怎么发送https请求。

var http=require('http'),
fs=require('fs'),
auth=new Buffer('user:password').toString('base64'),
op={
    host:'proxy.xxx.com',
    port:8080,
    method:'GET',
    path:'http://www.baidu.com/',        
    headers:{
        'Proxy-Authorization':'Basic '+auth
    }
};
var req=http.request(op,function(res){
console.log("status:",res.statusCode);
res.on('data',function(chunk){
    console.log('BODY:'+chunk);
});
});
req.on('error',function(e){
console.log('Error got: '+e.message);
console.log(e.stack);
});
req.end();

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档