如何用nodejs模拟get发送消息
1个回答
展开全部
供你参考:
client.js
var http = require('http');
http.get("http://127.0.0.1:3000/wechat?signature=d34f1983fb3ecf933b9435ad5c05b6e3a138a0e5&echostr=5898562696761927225×tamp=137", function(res) {
console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
server.js
var http = require('http');
var url = require('url');
var qs = require('querystring');
http.createServer(function(req, res) {
res.writeHead(200, {"Content-Type": "text/plain"});
var query = url.parse(req.url).query;
res.end(JSON.stringify(qs.parse(query)));
}).listen(3000);
client.js
var http = require('http');
http.get("http://127.0.0.1:3000/wechat?signature=d34f1983fb3ecf933b9435ad5c05b6e3a138a0e5&echostr=5898562696761927225×tamp=137", function(res) {
console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
server.js
var http = require('http');
var url = require('url');
var qs = require('querystring');
http.createServer(function(req, res) {
res.writeHead(200, {"Content-Type": "text/plain"});
var query = url.parse(req.url).query;
res.end(JSON.stringify(qs.parse(query)));
}).listen(3000);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |