如何修复无效参数
How to fix Invalid Parameter To
我正在尝试验证使用 Twilio 发送的代码。目前发送验证码的功能很好,但是验证码的功能没有正常使用。
我试过用 To
、verificationSid
、VerificationSid
和 none 替换参数 to
,它们似乎按预期工作。
exports.validateVerificationCode = functions.https.onRequest((req, res) => {
var number = req.body.number;
var code = req.body.code;
twilio.verify.services('VA{MY_SERVICE_ID}').verificationChecks.create({
to: number,
code: code
}).then((validation_check) => {
res.status(200).json(validation_check);
}).catch((err) => {
res.status(500).json(err);
console.log(err);
});
});
我希望函数 运行 如 API 文档中所示,但我的 firebase 控制台一直显示
"[Error: Invalid parameter: To]
status: 400" and when I replace 'to' with 'To', it gives me the following error "[Error: Either a 'To' number or 'VerificationSid' must be specified]
status: 400".
一些事情,您是否检查收件人号码:是否为 E.164 格式,https://www.twilio.com/docs/glossary/what-e164 and that you are using a more current version of the Twilio Node SDK Helper Library? https://github.com/twilio/twilio-node/blob/master/CHANGES.md。
我的工作代码看起来非常相似,所以我觉得这是上述两个问题之一(我使用 Twilio Node Helper Library 3.31.1 进行了测试)。
exports.handler = function(context, event, callback) {
const client = context.getTwilioClient();
const code = event.code;
let phoneNumber = event.phoneNumber;
client.verify.services('VA1exxxxxxbc6e02520c585xxxxxxxxxx')
.verificationChecks
.create({to: phoneNumber, code: code})
.then(verification_check => {
console.log(`***VERIFICATION STATUS***: ${verification_check.status}`);
// Object.keys(verification_check).forEach(thisKey => console.log(`${thisKey}: ${verification_check[thisKey]}`));
callback(null, `${verification_check.status}`);
})
.catch(err => {
console.log(err);
callback();
});
};
我正在尝试验证使用 Twilio 发送的代码。目前发送验证码的功能很好,但是验证码的功能没有正常使用。
我试过用 To
、verificationSid
、VerificationSid
和 none 替换参数 to
,它们似乎按预期工作。
exports.validateVerificationCode = functions.https.onRequest((req, res) => {
var number = req.body.number;
var code = req.body.code;
twilio.verify.services('VA{MY_SERVICE_ID}').verificationChecks.create({
to: number,
code: code
}).then((validation_check) => {
res.status(200).json(validation_check);
}).catch((err) => {
res.status(500).json(err);
console.log(err);
});
});
我希望函数 运行 如 API 文档中所示,但我的 firebase 控制台一直显示
"[Error: Invalid parameter: To] status: 400" and when I replace 'to' with 'To', it gives me the following error "[Error: Either a 'To' number or 'VerificationSid' must be specified] status: 400".
一些事情,您是否检查收件人号码:是否为 E.164 格式,https://www.twilio.com/docs/glossary/what-e164 and that you are using a more current version of the Twilio Node SDK Helper Library? https://github.com/twilio/twilio-node/blob/master/CHANGES.md。
我的工作代码看起来非常相似,所以我觉得这是上述两个问题之一(我使用 Twilio Node Helper Library 3.31.1 进行了测试)。
exports.handler = function(context, event, callback) {
const client = context.getTwilioClient();
const code = event.code;
let phoneNumber = event.phoneNumber;
client.verify.services('VA1exxxxxxbc6e02520c585xxxxxxxxxx')
.verificationChecks
.create({to: phoneNumber, code: code})
.then(verification_check => {
console.log(`***VERIFICATION STATUS***: ${verification_check.status}`);
// Object.keys(verification_check).forEach(thisKey => console.log(`${thisKey}: ${verification_check[thisKey]}`));
callback(null, `${verification_check.status}`);
})
.catch(err => {
console.log(err);
callback();
});
};