Python 如何向 Calls 资源提交 POST 请求?(在 Twilio 中拨打电话)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38949066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to submit a POST request to the Calls resource? (making outgoing calls in Twilio)
提问by bomalicay
I'm having trouble with making outgoing calls using Twilio and I believe I skipped this step where I should submit a POST request to the Calls resource. I don't really understand what to do with this and I need someone to explain it for me since I'm just a beginner. And by the way, my Twilio account is just free trial. Does this have something to do as to why I can't make local calls?
我在使用 Twilio 拨打电话时遇到问题,我相信我跳过了这一步,我应该向 Calls 资源提交 POST 请求。我真的不明白该怎么做,我需要有人为我解释,因为我只是一个初学者。顺便说一下,我的 Twilio 帐户只是免费试用。这与我为什么不能拨打本地电话有关系吗?
Thanks.
谢谢。
回答by philnash
Twilio developer evangelist here.
Twilio 开发人员布道者在这里。
Best place for you to start would be the Python making calls quick start. Follow that tutorial through and you should understand how to make a call with Python.
最适合您开始的地方是Python 调用 quick start。按照该教程进行操作,您应该了解如何使用 Python 进行调用。
Though, as you say, the key is the POST request to the calls resource. It's easiest to perform this using our Python helper libraryand looks a bit like this:
不过,正如您所说,关键是对调用资源的POST 请求。使用我们的Python 帮助程序库最容易执行此操作,看起来有点像这样:
from twilio.rest import TwilioRestClient
# Get these credentials from http://twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXX"
auth_token = "YYYYYYYYYYYYYYYYYY"
client = TwilioRestClient(account_sid, auth_token)
# Make the call
call = client.calls.create(to="+14085551234", # Any phone number
from_="+12125551234", # Must be a valid Twilio number
url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient") # Just plays hold music
Let me know if that helps at all.
让我知道这是否有帮助。