【发布时间】:2016-06-15 08:12:16
【问题描述】:
我想用我的手机拨打我的 Twilio 号码,Twilio 识别出我的号码,拒绝来电,然后给我回电。代码如下:
@application.route("/test", methods=['GET', 'POST'])
def test():
whitelist = ['81808730xxxx', '44753810xxxx', '+44753810xxxx', '+44792834xxxx', '44792834xxxx']
call_from = request.values.get('From', 'None')
if call_from in whitelist:
# "<Response><Reject /></Response>"
resp = twilio.twiml.Response()
resp.reject()
time.sleep( 10 )
account_sid = "account_sid"
auth_token = "account_auth_token"
client = TwilioRestClient(account_sid, auth_token)
call = client.calls.create(to=call_from, from_="+1646480xxxx", url="https://zshizuka.herokuapp.com/gather")
print call.sid
else:
resp = twilio.twiml.Response()
call_to = "+44792834xxxx"
resp.dial(call_to)
#return json.dumps({'success':True}), 200
return str(resp)
这会产生可怕的响应:“我们很抱歉发生了系统错误。再见”。
但是,如果我在第一次响铃后拨打该号码并挂断,则效果很好。所以我假设问题出在拒绝动词上。如您所见,我尝试过使用和不使用 twiml。
我想得到一个忙音,拒绝来电(这样不需要手机话费),然后回拨。
感谢您的帮助。
【问题讨论】: