Tag: curl

如何使用node-curl发布数据?

我对LINUX使用node.js很陌生。 它只是我的第二天。 我使用节点curlcurl请求。 在下面的链接中,我find了Get请求的例子。 任何人都可以使用node-curl为我提供Post请求示例。 https://github.com/jiangmiao/node-curl/blob/master/examples/low-level.js

如何用curl查询Node.js Express

我将通过一个简单的应用程序通过curltestingNodejs。 curl命令是: curl -i -X POST -H 'Content-Type: application/json' -d '{"name": "Name"}' http://localhost:3000/users 和Node.js运行如下: app.post('/users', users.addUser); 和用户的其他地方: exports.addUser = function(req, res) { console.log(req.query); //etc. 输出是{} 。 req.body,而不是定义。 我怎样才能检索curl参数? 我错过了什么吗?

Express中的查询参数被提取?

我正在为Node.JS编写一个AppleScript应用程序的API。 AppleScript应用程序以下面的forms运行在shell脚本中: do shell script ("cd " & quoted form of myDir & " curl http://localhost:5000/server.properties?some-value=true&next-value=something%20else&[…] -O") 它打算下载名为server.properties的文件到基于指定参数的内容的目录myDir ,但由于某种原因,当Express收到请求时,它显示只有当我运行console.log(res.originalUrl) : /server.properties?some-value=true 它将把这个请求视为没有其他参数被指定。 任何人都可以告诉我我做错了什么,或者如何找出错误的地方? 编辑原来是我运行shell脚本的方式。 该URL需要被引用,以便&在shell脚本中不作为操作符。

将http请求从cURL转换为Node http.request

我在Node中遇到了一些基本的身份validation问题。 以下是我可以通过cURL作为subprocess: var auth = 'Basic ' + new Buffer(username + ":" + password).toString('base64'); var url = 'https://' + hostname + path; var curlstr = "curl #{url} -H 'Authorization: #{auth}'" .replace('#{url}', url) .replace('#{auth}', auth); require('child_process').exec(curlstr, function (err, stdout, stderr){ console.log(stdout); }); 但是,当我尝试https.request时,它返回403s: var req = https.request({ hostname: hostname, path: path, headers: {'Authorization': auth} }, function […]

无法在hostmonster上运行express服务器

我能够在Hostmonster上运行node.js服务器。 当我冲浪到http://node.domain.com时 ,我得到了预期的html输出(其中'域'被replace为我的实际域名)。 现在我想要运行一个expressjs服务器。 在看了expressjs的这个教程之后: https : //www.youtube.com/watch? v = FqMIyTH9wSg,我创build了exp2014的目录和文件,运行了服务器,并成功得到了初始的“Welcome to express”网页,当我冲浪从命令行:curl http://node.domain.com:3000从我的Hostmonster帐户。 该video演示了如何设置一个响应“localhost:3000”的快速服务器,所以我调整了url到我的网站,如上所述,在ssh后用curl运行到我的Hostmonster帐户。 但是,当我尝试从我的Hostmonster帐户curl http://node.domain.com:3000时,curl命令超时。 当我尝试从chrome或任何其他浏览器浏览到http://node.domain.com:3000时,也是如此 。 为什么curl命令从我的Hostmonster帐户中成功运行,但是我无法从帐户外部浏览它(或者从帐户外部运行相同的curl命令)?

Node.JScallbackpost请求closures

嗨有什么办法来closuresnode.Js中的发布请求,这是我怎么做,它每10秒发生一次。 我不需要的回应,只需要拨打url只。 如果我们在linux中使用curl,有一种方法可以closures$curl->close() function callUrl(url, data){ var request = require('request'); request.post( url, {form: {data: data}}, function (error, response, body) { if (!error && response.statusCode == 200) { console.log(body) } } ); } 部署node.JS我永远使用https://www.npmjs.com/package/forever我遇到的问题是,因为我是一个新手我不知道为什么会发生这种情况,但服务器总是在90 %或以上,这种行为是永久运行节点app.js后。 forever start app.js 有没有人有类似的问题? 或者如果你没有永久使用,你是如何部署的? 通过键入w来检查服务器负载平均值 这就是我所说的function。 var cTask = setInterval(function() { var utcDate = moment.utc(); console.log('cron timer start: ' + […]

为什么电报设置webhook后不发送更新?

我可以通过Telegram getUpdates API获取更新,而在使用有效的SSL证书或自签名证书设置webhook后,它会显示: {"ok":true,"result":true,"description":"Webhook was set"} 但它不会发送任何更新到我的webhook链接(我检查了Nginx和node.js访问日志文件),我尝试了很多curl命令为setWebhook API与没有证书,但仍然没有结果: curl -s -X POST https://api.telegram.org/bot<TOKEN>/setWebhook -d url='https://www.example.tech/<TOKEN>/webhook' jq . curl -F "url=https://www.example.tech/<TOKEN>/webhook" -F "certificate=@./www_example_tech.crt" https://api.telegram.org/bot<TOKEN>/setWebhook

terminalcurl:(7)无法连接到本地主机端口3000:连接被拒绝

我正在使用OSX Elcapitan,10.11.6,当我运行 curl localhost:3000 要么 curl localhost:3000 -4 要么 curl 0.0.0.0:3000 要么 curl -x "" "http://127.0.0.1:3000" 它总是说: curl:(7)无法连接到127.0.0.1端口3000:连接被拒绝 ruby -v ruby 2.1.3p242(2014-09-19修订版47630)[x86_64-darwin13.0] 我的代码: var http = require('http'), express = require('express'), path = require('path'), MongoClient = require('mongodb').MongoClient, Server = require('mongodb').Server, CollectionDriver = require('./collectionDriver').CollectionDriver; var app = express(); app.set('port', process.env.PORT || 3000); app.set('views', path.join(__dirname, 'views')); app.set('view engine', […]

request.js失败,其中CURL通过授权标头成功获取GET请求

我可以使用curl的Authorization头进行GET请求,但不能使用Node.js中的request或https进行request 。 服务器使用curl返回状态200,使用request或https返回500。 来自request或https request可能与curl不同? 服务器如何以不同的方式读取它们? 以下cURL从命令行成功执行: curl -H "Authorization: Bearer abc123def456" https://api.domain.com/path/to/resource 但同样的请求失败,在Node中的request.js var options = { type: 'get', url: "https://api.domain.com/path/to/resource", headers: { "Authorization": " Bearer abc123def456" } } request(options, function (err, response, body) { assert.equal(response.statusCode, 200) ; // 500 internal error }) 使用auth选项,request.js也失败了: var options = { type: 'get', url: "https://api.domain.com/path/to/resource", auth: { […]

node.js POST请求失败

我试图用node.js执行一个POST请求,但似乎总是超时。 我也尝试使用cURL在PHP中的请求,只是为了确保工作正常。 另外,在本地服务器(127.0.0.1)而不是远程服务器上执行完全相同的请求时,它也可以很好地工作。 Node.js的: var postRequest = { host: "www.facepunch.com", path: "/newreply.php?do=postreply&t=" + threadid, port: 80, method: "POST", headers: { Cookie: "cookie", 'Content-Type': 'application/x-www-form-urlencoded' } }; buffer = ""; var req = http.request( postRequest, function( res ) { console.log( res ); res.on( "data", function( data ) { buffer = buffer + data; } ); res.on( […]