我正在开发一款应用,允许用户添加人物,信息和姓名/电话,或从iPhone联系人列表中选择多个号码,以便向所选号码发送短信。问题是每次都需要调用Twillio API。他们是否可以为多个号码调用API一次?
提前致谢
答案 0 :(得分:6)
这是不可能的,您需要遍历列表并为每条消息发出一个请求(这可能比批处理它并处理多个错误/重新发送的可能性更好)。
答案 1 :(得分:1)
是的,可以通过Twilio号码向多个用户发送消息。
您可以尝试使用node.js文件:
var arr = ["+1xxxxxxxxxx","+1xxxxxxxxx"];
arr.forEach(function(value){console.log(value);
client.messages.create({
to:value,
from: "+19253504188",
body: msg,
}, function(err,message){
console.log(err);
});
});
答案 2 :(得分:0)
每个来自Twilio的新SMS消息必须与单独的REST API请求一起发送。要向收件人列表发起消息,您必须向要发送消息的每个号码发出请求。最好的方法是建立一个收件人数组并遍历每个电话号码。
history = []
print("Options: 1) Integer Summation, 2) String concatenation, 3) Last Display, 4)Exit...")
def main():
def summation():
first_num = int(input("Type the first integer: "))
second_num = int(input("Type the second integer: "))
total_0 = first_num + second_num
print("Sum of two integers is: ",total_0)
history.append(total_0)
def string():
first_num = str(input(":ype the first string: "))
second_num = str(input("Type the second string: "))
total_1 = first_num + second_num
history.append(total_1)
print("Concatenation of two strings is: ",total_1)
def last():
print("The Previous result is: " + str(history()))
def exits():
print("Exiting...")
while True:
x = str(input("Type your option: "))
if x == "1" or x == "2" or x == "3" or x == "4":
break
if x == "1":
summation()
elif x == "2":
string()
elif x == "3":
last()
else:
exits()
main()