Tag: api

SailsJs Response(res)生命周期

有没有办法挂起一个函数或任务来航行的响应,在发射function之前,例如,我有几个res.ok(object_output) ; 基于一些条件和在单独的控制器,我想拦截每个res.ok(就像政策 )做一些事情之前,返回响应。

Express CORS不起作用

我刚开始使用我的nodejs express模板购买cors不工作。 我用npm install cors –save 这里是文件: var express = require('express'); var cors = require('cors'); var app = express(); app.use(cors()); var corsOptions = { origin: 'https://example.com/', optionsSuccessStatus: 200 }; app.get('/', cors(corsOptions), function(req, res, next) { res.json({ message: 'hooray! welcome to our api!' }); }); app.get('/tt', function(req, res, next) { res.json({ message: 'hooray! welcome to our […]

存储来自twitter api的数据javascript(nodejs)

我似乎有一个问题。 我试图导出数据从Twitter的API,但我不能。 这是我的代码看起来像: /// Twitter.js module.exports = Twitter function Twitter(twitter) { this.twitter = twitter } Twitter.prototype.friends = function(params) { this.twitter.get('friends/list', params, (err, data) => { if (err) console.log(err) console.log(data) // this prints data to the console but // I want to export and save in a data structure // array or object } } ///bot.js […]

在进行api调用时,Docusign遗留标头错误

尝试使用Docusign API的传统标头时收到错误消息。 这是我的代码 request({ headers: { "X-DocuSign-Authentication": [{ "Username": "zabie@toplevelstaging.com", "Password": "xxxxxxxx", "IntegratorKey": "xxxxxxxxxxx-11xxx2f567xxxx0dbxxxx2d" }] }, url: "https://demo.docusign.net/restapi/v2/accounts/3465212/envelopes", json: true, // <–Very important!!! body: data, method: "POST", }, function (error, response, body) { console.log(response.body); }); console.log(data[0].templateRoles[0].tabs.textTabs[0].value); console.log(data[0].templateRoles[0].roleName); res.redirect('/contracts'); }); 这是错误 { errorCode: 'INVALID_TOKEN_FORMAT', message: 'The security token format does not conform to expected schema.' }

一般术语放在上下文中

在学习任何其他编程语言之前,我学习了Java编程。 当我学习Node.js时,我得到了所有的术语混淆。 我一直认为API是一个方法库,类,等,有人build立了使我们的生活更容易。 然后我了解了模块,我基本上认为它和API(已经由某人build立的方法列表)是一样的。 那么,我了解了Express框架,它又是一个像模块和API一样的方法列表。 而且,我们将这些function整合到我们的程序中的方式都是通过类似的方式进行的 Var http = require('http'); 因此,理解这些术语之间区别的人是否可以将这些术语放在可以解决我的问题的上下文(示例)中。 非常感谢您的帮助。

使用Youtube API获取用户电子邮件

我怎样才能使用Youtube API获得authentication的用户电子邮件? 我尝试使用channels.list : GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&mine=true&key={YOUR_API_KEY} 它不会返回电子邮件… 我使用这个NodeJS模块与Youtube API进行通信: var Youtube = require("youtube-api"); Youtube.authenticate({ type: "oauth", token: ACCESS_TOKEN }); Youtube.channels.list({ "part": "brandingSettings", "mine": true }, function (err, data) { console.log(err, data); });

node.js oauth2服务器到服务器客户端(谷歌跟踪authentication)

我很难find如何做相对简单的事情.. 我正在编写一个node.js应用程序,我想利用Google Tracks API https://developers.google.com/maps/documentation/tracks/ track API使用OAuth2根据API帐户对服务器进行身份validation – https://developers.google.com/maps/documentation/tracks/auth 我想要做的只是使用node.js来validation我的应用程序与谷歌 我遇到的问题是,我可以find有关此主题的每个模块或框架都是关于将用户redirect到谷歌,并将它们返回给应用程序,这不是我想要实现的…相反,我想要只需将我的API凭证硬编码到服务器中,并直接对其进行身份validation,以便它可以使用API​​,那么当令牌过期时,我还需要一些方法来保持会话的活跃。 任何帮助将非常感激

Twilio Node.js APIdate格式

我试图从Twilio的Node.js API获取消息列表。 我想要在date大于或等于给定date发送的所有邮件: client.messages.list({ dateSent: '>=2013-10-04', }, function(err, data) { if (err) { console.log(err); } else { data.messages.forEach(function(message) { console.log(message.body); }); } }); 获取发送的绝对date很容易,这是有效的,但在文档中说: 在这里,在“列表filter”下,它指出: 仅显示在该date发送的消息(格式为GMT格式),以YYYY-MM-DD的forms给出。 示例:DateSent = 2009-07-06。 您还可以指定不等式,例如DateSent <= YYYY-MM-DD表示在date午夜前或之前发送的邮件,而DateSent> = YYYY-MM-DD表示在date午夜或之后发送的邮件。 所以这适用于一个URL参数,但我不知道如何将这个作为一个JSONparameter passing给客户端对象…. 我问Twilio的支持,但没有答案…

通过谷歌的API检索Google Analytics的行为stream程?

我成功使用node.js从Google Analytics下载了一些优秀的google-api-nodejs-client数据 。 不幸的是,我还没有find下载“ Behavior/Behavior Flow页面中提供的数据的方法。 任何人都有一些关于如何从API中检索stream数据的想法?

发送httppost请求到Bluemix部署的Node.js应用程序时,“不幸的是应用程序已经停止”错误

我正在创build一个Android应用程序,但使用httppost方法向Bluemix部署的Node.js服务器发送参数时,出现“不幸的应用程序已停止”错误。 有谁能帮我解决这个问题吗? 我有查询,无法从Node.js收到门票链接的响应: 我无法将我的请求参数发送到bluemix部署的node.js Jave代码如下: package com.example.rest; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import android.support.v7.app.ActionBarActivity; import android.app.Dialog; import android.content.SharedPreferences; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Adapter; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; […]