Twilio sendMessage不发送到数组中的所有值
Twilio sendMessage not sending to all values in an array
我有一个问题,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."
}
});
}
}
当我console log a[index]时,它记录了所有存储的数字,但当客户端。使用发送消息时,只发送其中一个号码,而不是全部。有什么原因吗?
由于您使用免费版本而发生问题。如果你想向所有号码发送短信,你必须验证它们才能继续。
为了验证一个号码去你的Twilio控制台,号码,验证来电显示还有加号。你可以选择接电话或发短信。
您也可以随时从仪表板升级您的Twilio帐户。
相关文章:
- 如何在映射数组中添加换行符
- javascript结合了数组和字典
- 需要帮助设置json数组
- 不能从angular2中的子组件指定父组件中的数组
- 使用JS将数组转换为json对象
- 数组在递归方法中设置为null
- knockoutjs可观察数组
- Javascript-如何读取json文件中的列并将其保存在Javascript数组中
- 将数组从PHP传递到Javascript
- JavaScript数组排序(函数)用于对表行进行排序,而不是排序
- 在函数中添加数组元素的数值
- 无法通过数组映射绑定
- javascript中的数组出错
- 如何使用 node.js 比较两个 json 数组
- Javascript(Angular)从一个对象数组到第二个数组查找值
- 根据id将json数组组合为一个json数组
- 如何通过数组更新角度子范围
- 有没有一种方法可以添加相同的项目val=“0”;4〃;到JavaScript中数组的每个对象
- 在Javascript中转换对象数组
- Twilio sendMessage不发送到数组中的所有值