python - Twilio Python:如何通过 twilio 调用多个调用
问题描述
我想在 python 上通过 Twilio 呼叫多部电话我刚刚看到 Twilio 博客,但我没有理解这是我的脚本
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client
account_sid = "AC723c6c38e7c58a572ce011a652540a42"
auth_token = "REDACTED"
client = Client(account_sid, auth_token)
# Your Account Sid and Auth Token from twilio.com/console
# and set the environment variables. See http://twil.io/secure
call = client.calls.create(
)
print(call.sid)
那么你能告诉我该怎么做吗
解决方案
Twilio 开发人员布道者在这里。您应该创建一个要调用的电话号码数组,然后遍历该数组,调用calls.create
方法来调用作为参数传入的数组中的每个号码calls.create
。
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client
account_sid = "AC723c6c38e7c58a572ce011a652540a42"
auth_token = "REDACTED"
client = Client(account_sid, auth_token)
# Your Account Sid and Auth Token from twilio.com/console
# and set the environment variables. See http://twil.io/secure
arr = ['INSERT-NUMBER-TO-CALL', 'INSERT-OTHER-NUMBER-TO-CALL'...]
for num in arr:
call = client.api.account.calls.create(
to=num,
from_='YOUR-TWILIO-NUMBER',
url = 'http://demo.twilio.com/docs/classic.mp3'
)
print(call.sid)
或者,url
您可以使用它来播放消息,而不是包含指向您要在手机上播放的文件的链接twiml='<Response><Say>INSERT MESSAGE HERE</Say></Response>',
。您可以使用不同的 Amazon Polly 语音来自定义说出消息的语音 -更多信息请点击此处。
推荐阅读
- php - 如何替换字符串中的所有非字母数字字符?
- mysql - NodeJS Mysql 模块在远程数据库上抛出 ETIMEDOUT 错误
- gradle - 如何在没有根目录的情况下创建“tar.gz”包?
- c++ - 如何将 notifier() 与 compose() 一起使用?
- matlab - matlab如何在另一个矩阵中插入一个矩阵
- swift - 将 ARReferenceImage 从阵列上传到 Firebase 存储
- php - PHP:如何通过循环推送键/值对?
- javascript - 在图像滑块之前的触摸手势
- python - rasa_core.exceptions.UnsupportedDialogueModelError:模型版本:0.0.0 实例版本:0.12.3 最低兼容版本:0.12.0
- javascript - Vue表单未提交