Tag: curl

用于Webhook的Node.JS https服务器获取握手错误

下面的NodeJS只是处理来自另一个源的webhook。 我testing了它,它在http端口80上工作,但源需要https。 当我打开该端口并在443上运行此脚本时,使用curl进行testing会得到以下错误。 但是我不认为应该要求证书吗? 我怎么解决这个问题? curl: (35) SSL peer handshake failed, the server most likely requires a client certificate to connect 这是脚本: var http = require('https') var server = http.createServer(function(req, res) { if (req.method == "POST") { var str = '' req.on('data', function(data) { str += data }) req.on('end', function() { var json = JSON.parse(str) […]

curl获取POST响应,但node.js没有获得POST响应

当我使用下面的命令时,我得到正确的JSON响应: $ curl –data "regno=<reg-number>&dob=<dob>&mobile=<mobile>" https://vitacademics-rel.herokuapp.com/api/v2/vellore/login 当我使用下面的节点JS代码,我没有得到回应: var request= require('request'); var querystring=require('querystring'); var credentials={regno: '13bit0036', dob:25051995, mobile:9431222422}; console.log(querystring.stringify(credentials)); request.post({ url: 'https://vitacademics-rel.herokuapp.com/api/v2/vellore/login', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body:querystring.stringify(credentials), }, function(error, response, body){ if(error) { console.log(error); } else { console.log(response.statusCode + '\n' , body); } });

如何在节点中使用客户端证书进行HTTPS GET

我可以使用curl来进行GET请求 – > `curl -v https://example.com:82/v1/api?a=b` -E client_cert.pem:password 我怎样才能在节点中使用相同的。 我试过请求,绝对不能通过证书。 提前致谢!

本地主机,和映射主机在etc / hosts工作,但127.0.0.1不

伟大的神秘。 我有一个运行在OS X El Capitan上的Express / Node(v4.2.2)JS应用程序。 该应用程序运行在端口4444.如果我运行的应用程序,我能够得到正确的回应与以下命令: curl localhost:4444 – >工程 curl [::1]:4444 – >工程 curl api.q.com:4444 – >工程 不过,我有一个问题: curl 127.0.0.1:4444 – > 不起作用; 以 curl: (52) Empty reply from server 在所有浏览器中, 127.0.0.1:4444失败。 更令人惊讶的是, 除了 Chrome以外, api.q.com:4444可以在所有浏览器中使用。 我的/etc/hosts文件: 127.0.0.1 localhost web.q.com api.q.com qrm.q.com fhr.q.com ::1 localhost fe80::1%lo0 localhost 我已经尝试将我的/etc/hosts文件重置为默认值,并刷新了我的DNScaching。 我有一种感觉可能是应用程序,但我不知道是什么原因。 有什么build议么?

如何使用MailChimp API发送电子邮件

我在nodejs中创build一个应用程序来使用MailChimp发送一封电子邮件。 我试图使用https://apidocs.mailchimp.com/sts/1.0/sendemail.func.php,但将其改为使用3.0 API,因为1.0似乎不再工作(大惊喜)。 我已经安装了我的应用程序 var apiKey = '<<apiKey>>', toEmail = '<<emailAddress>>', toNames = '<<myName>>', message = { 'html': 'Yo, this is the <b>html</b> portion', 'text': 'Yo, this is the *text* portion', 'subject': 'This is the subject', 'from_name': 'Me!', 'from_email': '', 'to_email': toEmail, 'to_name': toNames }, tags = ['HelloWorld'], params = { 'apikey': apiKey, 'message': message, […]

expression和压缩,找不到我所犯的错误:-(

我找不到为什么我无法压缩我的内容。 我尝试了很多方法,但是当我在静态页面或基本本地内容(/)上检查curl(curl -I -H'Accept -Encoding: gzip'http:// localhost:8080 / free.html )时,find任何方式来压缩我的内容 我做错了什么? 这是我的代码: var express = require('express'); var compression = require('compression'); var morgan = require('morgan'); var favicon = require('serve-favicon'); var app = express(); app.use(compression({ filter: function () { return true; } })); app.use(morgan('combined')); app.use(favicon(__dirname + '/public/favicon.ico')); app.use(express.static(__dirname + '/public')); app.get('/', function(req, res) { res.setHeader('Content-Type', 'text/plain'); res.end('Vous […]

axios相当于curl –upload-file

我试图用他们的公共API上传一个gif给Gfycat。 这是在命令行上使用cURL完成的: curl https://filedrop.gfycat.com –upload-file /tmp/name 我试图用axios把它转换成Node.js: axios.post("https://filedrop.gfycat.com", { data: fs.createReadStream("/tmp/name") }).then(console.log).catch(console.log); 但与消息的错误 <?xml version="1.0" encoding="UTF-8"?>\n<Error><Code>PreconditionFailed</Code><Message>At least one of the pre-conditions you specified did not hold</Message><Condition>Bucket POST must be of the enclosure-type multipart/form-data</Condition><RequestId>6DD49EB33F41DE08</RequestId><HostId>/wyrORPfBWHZk5OuLCrH9Mohwu33vOUNc6NzRSNT08Cxd8PxSEZkzZdj/awpMU6UkpWghrQ1bLY=</HostId></Error> 被打印到控制台。 我的Node.js代码如何与cURL命令不同,以及使用axios到cURL命令的等效代码是什么?

Koajs和curl与内容编码:gzip,放气

我正在寻找客户端(使用curl)和Koajs服务器与内容编码之间交换数据的简单示例:gzip,deflate。 更多细节:客户端有日志文件。 客户端压缩日志文件并将日志文件发送到服务器。 服务器解压日志文件并获取内容。 请给我curl命令和Koajs代码。 谢谢。

POST请求types错误 – 无法读取未定义的属性

我正在向我的mongo服务器发送一个curl请求,并且请求总是说“不能读取属性”的用户名'undefined“。 我最好的猜测是我的curl请求格式不正确,这将解释未定义的请求,但它看起来很好。 任何人都可以看到这里的问题是什么? curl请求: curl "http://localhost:3000/api/users" \ –include \ –request POST \ –data '{ "user": { "username": "testuser", "email": "test@email.com", "pwd": "pass" } }' 用户路由: const router = require('express').Router() const bcrypt = require('bcryptjs') const User = require('../models/user') router.post('/', (req, res) => { const user = new User({ username: req.body.user.username, email: req.body.user.email, passhash: bcrypt.hashSync(req.body.user.pwd, 10) }) […]

如何在NodeJS请求模块中做这个curl请求?

curl -H "Authentication: <security token>" "https://a.bcsc.com/app/api/v2/<api-key>/<query type>?<optional parameters>" request({ url: <<endpoint>>, headers: { Authentication: mpulseAuthToken } },function (error, response, body) { if(error) { console.log(error.message); } else { console.log(body); } }); 如何使用请求模块在Node JS中进行上述curl请求。 我已经有了安全标志。