【发布时间】:2020-02-23 03:12:34
【问题描述】:
我正在尝试使用 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")
}
})
})
我的凭据是正确的。 发生此问题的原因可能是什么,非常感谢您的帮助
提前致谢
【问题讨论】:
标签: node.js twilio one-time-password