Tag: webhooks

用于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) […]

Node.js无法从电报bot websocket中获取数据

我正在尝试使用自签证书与nodejs https服务器build立一个电报机器人。 ssl证书: openssl req -newkey rsa:2048 -sha256 -nodes -keyout key.pem -x509 -days 365 -out crt.pem -subj "/C=IR/ST=A.Sh/L=Tabriz/O=DominoSystem/CN=5.235.36.42" 非常简单的服务器: var options = { key : fs.readFileSync(__dirname + '/key.pem'), cert: fs.readFileSync(__dirname + '/crt.pem') }; https.createServer(options, function (req, res) { console.log('https server'); console.log(req.url); res.end('yoo hooo'); }).listen(8443,'0.0.0.0'); 服务器可通过Internet访问: https://5.235.36.42:8443/ : https://5.235.36.42:8443/ : https://5.235.36.42:8443/ Telegram bot setWebhook返回ok {"ok":true,"result":true,"description":"Webhook was […]

使用Webhook在Slack上发布自定义的JSON消息

如何发布自定义JSON消息与格式和缩进使用松散webhook? 我正在使用nodejs应用程序 var Slack = require('slack-node'); var JsonMessage = process.argv[2]; webhookUri = "https://hooks.slack.com/services/XXXX/xxxx/xxxxxxxx"; slack = new Slack(); slack.setWebhook(webhookUri); var textmsg = '“`' + JsonMessage + '“`'; slack.webhook({ channel: "#status", username: "Monitor Bot", icon_emoji: ":ghost:", text: textmsg }, function(err, response) { console.log(response); }); 上面的代码有助于发送JSON,但没有格式化。 它来作为一个string。 我想有JSON缩进。 谢谢。

在Trello上查找现有的Webhooks ID

我已经使用Trello的API( Node JS包 )添加了webhooks。 我如何获得当前的webhook,或者如何获得现有的webhook ID? 无法find通过API的方法: https : //developers.trello.com/advanced-reference/webhook 这里说: 有三种方法可以删除webhooks。 在webhook上使用DELETE路由DELETE https://api.trello.com/1/webhooks/[WEBHOOK_ID]?key=[APPLICATION_KEY]&token=[USER_TOKEN] 如果来自Trello的webhook请求在发送到callbackURL时收到HTTP 410 Gone响应,则WebHook将被删除。 如果webhook绑定的标记被撤销或过期,则webhook将被删除 第一种方法需要身份证,第二种方法要求我每次要删除一个webhook都取下服务器,第三种方法不是更好。 任何想法如何获得ID?

parsing内容Webhooks(自定义JSONtypes)

目前,我正在使用此Contentful-webhook服务器在内容未发布时侦听webhook。 server.listen(30000, function(){ console.log('Contentful webhook server running on port ' + 30000) }); server.on('ContentManagement.Entry.publish', function(req){ console.log('An entry was published!', req); }); server.on('ContentManagement.Entry.unpublish', function(req){ console.log('An entry was unpublished!'); console.log('Deleted SOLR ID: ', req); }); 我试图parsing我得到的响应,但我似乎无法find一种方法来parsing它们在响应中使用的自定义JSON。 我应该创build自己的服务器与快递还是缺less一种方法来获得在这个示例代码中的响应正文。

validationFacebook X-Hub-Signature

在parsing云代码我试图validation从Facebook webhook收到的头部x-hub-signature 。 secret是Facebook应用程序的正确密钥。 var hmac, expectedSignature, payload = JSON.stringify(req.body), secret = 'xyzxyzxyz'; hmac = crypto.createHmac('sha1', secret); hmac.update(payload, 'utf-8'); expectedSignature = 'sha1=' + hmac.digest('hex'); console.log(expectedSignature); console.log(req.headers['x-hub-signature']); 但签名永远不会匹配。 哪里不对?

如何响应电报僵尸Webhook请求? 相同的请求重复

我正在使用官方的电报bot api来制作一个使用nodejs的电报机器人(用于学习目的)。 我设置了一个webhook heroku。 我可以回复这个请求,但是经过一段时间之后,同样的请求会再次出现。 得到相同的请求是正常的,还是我没有回应接下来的请求。 当我调用getwebhookinfo方法时,它显示了pending_update_count,但是我的代码确实响应了来自webhook的所有请求。 我用这个来回复即将到来的请求 var express = require('express'); var bodyParser = require('body-parser'); var app = express(); var config = require('./lib/config'); var request = require('request'); var port = process.env.PORT || 3000; var reply_url = "https://api.telegram.org/bot"+config.bot_token; app.use(bodyParser.json()); app.get('/',function(req,res) { res.send("Working"); request({ url: "https://api.telegram.org/bot"+config.bot_token+'/getMe', json : true }, (err,res,body)=>{ console.log(body); }); }); app.post('/'+config.bot_token , […]

HMAC签名与github中的x-hub-signature不匹配

我正在处理来自github的传入Webhook,并且想要validationx-hub-signature。 我使用hmac来散列“秘密”,然后比较这两个哈希值。 问题是他们从来不匹配。 这是我的设置: router.route("/auth") .post((req, res) => { var hmac = crypto.createHmac("sha1", process.env.WEBHOOK_SECRET); var calculatedSignature = "sha1=" + hmac.update(JSON.stringify(req.body)).digest("hex"); console.log(req.headers["x-hub-signature"] === calculatedSignature); // Returns false console.log(req.headers["x-hub-signature"]) // => sha1=blablabla console.log(calculatedSignature) // => sha1=foofoofoo res.end(); }); 我已经尝试了一切,但不能使它工作。 想知道如果hmac.update()应该保存另一个参数比JSON.stringify(req.body) 。 有谁知道他们为什么不匹配?

基于时间的通知服务

我正在处理用户订阅计划并且到期的订阅。 所以基本上每个用户商店都有一个expiration字段。 我希望能够在用户计划一过期就能得到通知。 现在,我有一个工作,每天运行一次所有用户,并检查是否有人过期,但理想情况下,我希望得到一个服务器回发或某种事件,每当用户过期而不运行这一天。 你能想到任何处理这些事情的第三方服务/数据库/其他工具吗? 很多服务,例如Stripe,当用户的订阅被更新/过期时,都会通过webhook通知您。 他们只是像我一样反复地工作? 希望我已经说清楚了,希望能帮助我把search引向Google。 我目前的堆栈是Mongodb,Node.js,AWS 谢谢

将多重意图映射到使用一个DialogFlowApp的actionMap的一个函数

我正在使用Dialogflowbuild立一个应用程序。 用户回答一些问题,稍后可以查看他们的答案。 我的问题是与build立服务器返回用户以前的答案。 这是迄今为止的代码,意图是QUESTION_1和QUESTION_2,参数是GRATEFUL_1和GRATEFUL_2: 'use strict'; process.env.DEBUG = 'actions-on-google:*'; const App = require('actions-on-google').DialogflowApp; const functions = require('firebase-functions'); // a. the action names from the Dialogflow intents const QUESTION_1 = 'Question-1'; const QUESTION_2 = 'Question-2'; // b. the parameters that are parsed from the intents const GRATEFUL_1 = 'any-grateful-1'; const GRATEFUL_2 = 'any-grateful-2'; exports.JournalBot = functions.https.onRequest((request, […]