我正在使用twilio并尝试在我的index.js文件中发布到我的/testing
函数,但是我收到错误error: {unauthorized}
。我有一种感觉它与api键有关,但我不确定。我在请求的标题中传递了我的主密钥和应用程序ID,但我仍然得到相同的错误。我发布到https://xxxxxx.herokuapp.com/parse/index/test。
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://xxxxxxx',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
fileKey: process.env.FILE_KEY || 'xxxxxxxx',
appId: process.env.APP_ID || 'xxxxxxx', //
masterKey: process.env.MASTER_KEY || 'xxxxxx', // Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'https://xxxxxxx.herokuapp.com/parse', // Don't forget to change to https if needed
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
}
});
var app = express();
var twilio = require('twilio');
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);
app.post('/test', twilio.webhook({ validate: false }), function (req, res) {
console.log("use-sms") //Not printed, get the error "error:{unauthorized}"
from = req.body.From;
to = req.body.To;
body = req.body.Body;
gatherOutgoingNumber(from, to)
.then(function (outgoingPhoneNumber) {
var twiml = new twilio.TwimlResponse();
twiml.message(body, { to: outgoingPhoneNumber });
res.type('text/xml');
res.send(twiml.toString());
});
});