K.S*_*K.S 7 one-time-password node.js twilio
我正在尝试使用 Twilio API 向号码发送短信,但收到类似错误[RestException [Error]: The 'To' number 9977428080 is not a valid phone number.] {
status: 400,
message: "The 'To' number 9977428080 is not a valid phone number.",
code: 21211,
moreInfo: 'https://www.twilio.com/docs/errors/21211',
detail: undefined
}
在此之前,the from number is not valid我将 API 的凭据测试切换为实时凭据,然后我遇到了另一个问题。这些是下面的代码
const client = require('twilio')(config.SId, config.AccesToekn);
// SEND OTP TO USER ACCOUNT
router.post('/sendsms',(req, res, next)=>{
client.messages.create({
from:'+15204770942',
to:"9977428080",
body:'Please user this OPT to verify your number 74536',
}, function(error, data){
if(error){
console.log(error,'error')
console.log(data,"data")
}
})
})
Run Code Online (Sandbox Code Playgroud)
我的凭据是正确的。发生此问题的原因可能是什么,我们将非常感谢您的帮助
提前致谢
error.moreInfo: ' https://www.twilio.com/docs/errors/21211 '
进一步说明格式:
示例:+14155552671
改成:
const client = require('twilio')(config.SId, config.AccesToekn);
// SEND OTP TO USER ACCOUNT
router.post('/sendsms',(req, res, next)=>{
client.messages.create({
from:'+15204770942',
to:"+9199778080", //this must be a verified phone number for twilio trial accounts
body:'Please user this OPT to verify your number 74536',
}, function(error, data){
if(error){
console.log(error,'error')
console.log(data,"data")
}
})
})
Run Code Online (Sandbox Code Playgroud)