我想创建使用sms网关发送消息的web访问。
我有一个这样的url:
http://162.211.84.203/sms/smsreguler.php?username=zzz&key=xxx&number=628978520815&message=asdasd如何使用Node.js打开url?
发布于 2016-08-07 14:13:45
request的官方文档
npm install request --save //install it first
var request = require('request'); //require somewhere and use
var url = 'http://162.211.84.203/..'; //omitted for brevity
request(url, function(err, response, body) {
// Do more stuff with 'body' here
});发布于 2016-08-07 16:43:51
一种选择,也是我首选的方法是使用axios包。
用于浏览器和node.js的基于
Promise的HTTP
首先将axios安装到你的package.json中
npm install --save axios或npm i -S axios
然后,要求axios进入相应的文件,并向相应的发送get请求
var axios = require('axios')
axios.get('http://162.211.84.203/sms/smsreguler.php?username=zzz&key=xxx&number=628978520815&message=asdasd')
.then(function (res) {
console.log(res);
// ... do something with the response
})
.catch(function (error) {
console.log(error);
});没有看到你的部署,我只能说这么多了。很乐意根据您的情况提供更多信息。
https://stackoverflow.com/questions/38811259
复制相似问题