SMSメッセージングレスポンスに関連するTwilioドキュメント(https://www.twilio.com/help/faq/why-does-my-twilio-number-respond-with-thanks-for-the-message-configure-your-numbers-sms-url-to-change-this-message)の一部を読んでおり、着信SMSメッセージに応答できるnode.jsアプリケーションを構築しようとしていますプログラム的な対応でRESTクライアントを介して返信/node.jsを使用したインバウンドTwilioメッセージの処理
var AUTH_TOKEN = "*********************";
var twilio = require('twilio');
var express = require('express');
var http = require('http');
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded());
app.post('/welcome/sms/reply/', function(req, res) {
//Validate that this request really came from Twilio...
if (twilio.validateExpressRequest(req, AUTH_TOKEN)) {
var twiml = new twilio.TwimlResponse();
twiml.say('Hi! Thanks for checking out my app!');
res.type('text/xml');
res.send(twiml.toString());
}
else {
res.send('you are not twilio. Buzz off.');
}
});
http.createServer(app).listen(3000);
POSTリクエスト/歓迎/ SMSを呼び出す:私は同様の問題(How can I respond to incoming Twilio calls and SMS messages using node.js?)を扱うこのSOポストをエミュレートし、次のコードを持ってしようとしてきた
elseステートメントを生成します。なぜなら、AUTH_TOKENはアカウントのダッシュボードにあるものなのです。
ありがとうPhil - それは私がngrokを設定していなかったと私のTwilioアカウントで要求URLを正しく変更していなかったので、一度すべてがうまくいったことを修正しました。 –
ああ、私は見る!うれしいことは今あなたのために働いています。 – philnash