Tag: api

如何在swift中显示API的图像?

我希望能够在swift中显示由我的nodeJS API( http://my_api/getUserImg )发送的图像。 这个具体的路线是像这样返回一个图像: fs.readFile(my_file.jpg', function(err,data) { if (err) res.json({success: false, message: err}); res.send(data);` } 谢谢,

Sendgrid发送没有embedded代码的HTML电子邮件

我只想直接input我的HTML文件,input./blabla.html,而不是创build一个广告系列或模板。 有没有办法发送邮件没有把embedded式代码? 如果是这样,我会很高兴,谢谢! 我目前的代码如下所示: var helper = require('sendgrid').mail from_email = new helper.Email("blabla@hotmail.com") to_email = new helper.Email("heyhey@gmail.com") subject = "Merhaba !" content = new helper.Content("text/plain", "selam") mail = new helper.Mail(from_email, subject, to_email, content) } var sg = require('sendgrid').SendGrid("mysecretapikey") var requestBody = mail.toJSON() var request = sg.emptyRequest() request.method = 'POST' request.path = '/v3/mail/send' request.body = requestBody sg.API(request, […]

Uber API – 使用非开发人员login时invalid_grant

我正在使用Node-uber与Uber API进行通信。 我必须遵循以下代码(项目的示例代码几乎完全相同,密钥隐藏) var uber = new Uber({ client_id: 'XXXXXXXXXXXX', client_secret: 'XXXXXXXXXXXXX', server_token: 'XXXXXXXXXXXX', redirect_uri: 'https://localhost:3002/rides/callback', name: 'app name', language: 'en_US', sandbox: true }); router.get('/login', function(request, response) { var url = uber.getAuthorizeUrl(['request']); console.log(url); response.redirect(url); }); router.get('/callback', function(req, res, next) { uber.authorization({ authorization_code: req.query.code }, function(err, access_token, refresh_token) { if (err) { console.error(err); } else { […]

天气 – >简单的API在Node.js->如何发送android推送通知?

我们正在为我们的移动应用程序使用azure easy API(node.js)。 我们已经build立了通知中心,并对它们进行了testing – 它们似乎都在工作。 但是,我们不确定如何在易用的API中调用这些通知中心 – 我们已经遵循了Microsoft提供的所有文档(例如: http : //azure.microsoft.com/en-us/documentation/articles/notification-hubs -nodejs-how-to-use-notification-hubs / )并尝试了很多东西。 有人可以指出如何从Easy API发送推送通知的例子/代码片段? 谢谢Sankar

如何获得用户使用Spotify Web API的播放列表?

我正在开发一个项目,我希望得到在spotify上login用户的所有播放列表。 目前我可以login并查看用户信息(通过在spotify上进行演示)。 现在我想获取login的用户的播放列表,这是我卡住的地方。 这是我有的代码: /** * This is an example of a basic node.js script that performs * the Authorization Code oAuth2 flow to authenticate against * the Spotify Accounts. * * For more information, read * https://developer.spotify.com/web-api/authorization-guide/#authorization_code_flow */ var express = require('express'); // Express web server framework var request = require('request'); // "Request" library […]

Slack Bot在Node js中回复自己的消息

我试图在nodejs中做一个松散的机器人,它根据用户的input回复用户。 但是到目前为止,机器人不断地回复自己的信息 这是我的机器人的代码 let Bot = require('slackbots'); // create a bot let settings = { token: 'xoxb-10584202949', name: 'BotHelp'}; let bot = new Bot(settings); bot.on('start', function() { bot.postMessageToChannel('general', 'At your service'); }); bot.on('message',function (data) { console.log(data); if (data.username != "BotHelp" && data.subtype != 'bot_message'){ bot.postMessageToChannel('general', 'Yoooo'); } }); 控制台logging数据 打印 { type: 'hello' } { […]

创build.json文件的代码片段不起作用

我有这个代码,它的东西是,我需要它从该网站获取一些数据,string在apiurl 。 这段代码需要下载这些网站,在json中find一些appids。 它需要下载这些网站上的数据并将它们存储在一个json文件中。 由于某种原因,这是行不通的。 我有一个.js文件中的这段代码: var gamekeys = JSON.parse(fs.readFileSync('gamekeys.json')); var jsonstring = JSON.stringify(gamekeys, null, 4); UpdateGamePricelist(); function UpdateGamePricelist() { for(var i = 0;i<gamekeys.keys.length;i++) { appid = gamekeys.keys[i].appid; var apiurl = "http://store.steampowered.com/api/appdetails?appids="+appid; if (i < 95) { request(apiurl, function(err, response, body) { if (err) { console.log("Error when updating game prices: " + err+"\n"); return; } […]

产品广告API无效

我刚刚join亚马逊产品广告api副学士课程。 我能够在暂存器中运行查询,但在编码时它给出了错误。 请给我任何build议,如果我错了。 我正在使用Node.JS。 const OperationHelper = require('apac').OperationHelper; const opHelper = new OperationHelper({ awsId: '', awsSecret: '', assocId: 'tarun123-21' }); opHelper.execute('ItemSearch', { 'SearchIndex': 'Books', 'Keywords': 'harry potter', 'ResponseGroup': 'ItemAttributes,Offers', 'Service' : 'AWSECommerceService' }).then((response) => { console.log("Results object: ", response.result); console.log("Raw response body: ", response.responseBody); }).catch((err) => { console.error("Something went wrong! ", err); }); 它给出了以下错误: Results […]

node.js和routing:按类发出

新手问题如下: 我很难让EventEmitter工作。 我已经考虑过这样的文档和几个最好的教程: https : //code.tutsplus.com/tutorials/managing-the-asynchronous-nature-of-nodejs-net-36183 问题是,在user.js(Class)this.emit()中没有任何结果。 userRoutes.js不触发任何user.on(),我真的不知道为什么.. 任何build议表示赞赏。 提示更好的结构也。 我的目标是集中端点(可读性强),并在不同模块中重用每个模块(如用户或产品/订单)的代码,例如调用更新用户端点的订单。 所以,假设你有一个模块configuration的node.js-Server,路由器和几个类,如下所示: /server.js global.__base = __dirname + "/"; var server = require("http").createServer(); var routes = require("./v2"); var initialize = require(global.__base + "config"); var app = initialize.globalModules(); app.use('/api/v2', routes); app.listen('8090'); /config.js var db; module.exports = { globalModules: function() { // load the global modules var app […]

使用$ http将数据从angularJS发布到Express

我想这样发送一些JSON数据从angularjsexpression/ nodejs AngularJS代码: $http({ method: 'POST', url: 'http://localhost:8000/api/auth', data: { name: user, password: passwd }, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }) .success(function(data, status, headers, config) { $scope.loginStatus = data; }) .error(function(data, status, headers, config) { $scope.lloginStatusogin = data; }); ExpressJS代码: var express = require('express'); var app = express(); var config = require('./config'); // get our […]