gpt4 book ai didi

javascript - Twilio sendMessage 未发送到数组中的所有值

转载 作者:太空宇宙 更新时间:2023-11-04 00:33:47 28 4
gpt4 key购买 nike

我遇到 Twilio 未向数组中的所有值发送消息的问题。

    var index;
var a = req.body.numbers;
console.log(a);

if (req.body.numbers.indexOf("undefined") > -1) {
console.log("No numbers stored");
} else {
for (index = 0; index < a.length; ++index) {
console.log(a[index]);
client.sendMessage({

to: a[index], // Any number Twilio can deliver to
from: '+19179246693 ', // A number you bought from Twilio and can use for outbound communication
body: req.body.title + ": " + req.body.message // body of the SMS message

}, function(err, responseData) { //this function is executed when a response is received from Twilio

if (!err) { // "err" is an error received during the request, if any

// "responseData" is a JavaScript object containing data received from Twilio.
// A sample response from sending an SMS message is here (click "JSON" to see how the data appears in JavaScript):
// http://www.twilio.com/docs/api/rest/sending-sms#example-1
console.log(responseData.to);
console.log(responseData.from); // outputs "+14506667788"
console.log(responseData.body); // outputs "word to your mother."

}
});


}
}

当我控制台记录 [index] 时,它会记录存储的所有数字,但是当使用 client.send 消息时,仅发送其中一个数字,而不是全部。这有什么原因吗?

最佳答案

出现此问题是由于您使用免费版本。如果您想向所有号码发送短信,您必须验证它们才能继续。

要验证号码,请转至 Twilio 控制台、号码、已验证的来电显示和加号。您可以选择接听电话或短信。

您还可以随时从仪表板升级您的 Twilio 帐户。

关于javascript - Twilio sendMessage 未发送到数组中的所有值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40005789/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com