我已經嘗試了大部分解決方案,但無法弄清楚爲什麼我的調用未到達另一側。雖然Twilio說傳入和傳出都成功完成。Twilio調用返回「出現應用程序錯誤」
這裏是我的代碼的必要組成部分
from flask import Flask
from flask import request, Response
@app.route('/makeACall', methods=['POST'])
def exchange_voice():
account_sid = "XXXX"
auth_token = "XXXX"
client = TwilioRestClient(account_sid, auth_token)
call = client.calls.create(
to="+1857XXX",
from_="+1510XXX",
url="cloudserver.com/answerWithXML",
method='POST'
)
print(call.sid)
@app.route("/answerWithXML", methods=['GET', 'POST'])
def sendBackXML():
resp = twilio.twiml.Response();
resp.say("Welcome!");
//Was originally sending str(resp) as in docs
return Response(resp, content_type="application/xml")
使用調試器
- 「11200 - HTTP檢索失敗」,爲返回的響應
- 「12100 - 文檔解析失敗」 時str(resp)已退回
當您在瀏覽器中向您的'answerWithXML'路由發出GET請求時會發生什麼?你是否也正確地導入了'twilio'庫(我只看到Flask的進口)? – philnash
@philnash是的,twilio進口已正確添加。我錯過了這裏。當我返回str(resp)時,GET請求顯示「Welcome!」。即使那樣,通話也沒有完成。但是,消息傳遞完美無缺。 –
我想知道我們是否可以通過試用帳戶撥打電話。由於我正在嘗試API,因此我沒有升級到完整帳戶。 –