簡體   English   中英

Twilio:創建兩個撥出電話並使用Python加入會議

[英]Twilio: Create two outgoing calls and join the conference using Python

我正在嘗試使用Python / Django使用Twilio創建最多2位發言人的會議應用程序。 但是,在文檔中,我發現您可以通過進行入站呼叫來做到這一點。 但是,我的商業模式不能那樣工作。 有沒有辦法像這樣工作:

  • 我的Twilio號碼撥打了1號電話
  • 我的Twilio號碼致電2
  • Twilio為新會議帶來了兩個渠道

我已經嘗試過這種解決方案: Twilio如何進行兩個出站呼叫並使用node js加入(會議)它們,但並沒有太大幫助。

這是我的代碼:

@csrf_exempt
def conference(request):
    print("success")
    response = VoiceResponse()
    dial = Dial()
    dial.conference('Rooxm 1234')
    response.append(dial)
    print(response)
    return HttpResponse('')

def call(number):
    client = Client(TWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKEN)
    call = client.calls.create(
        url='https://<blahblah_removed_purposefully>.ngrok.io/conf/',
        to='+' + str(number),
        from_='<removed_my_twilio_num>'
    )
    print(call.sid)

def index(request):
    if request.method == 'POST':
        # create a form instance and populate it with data from the request:
        form = CallForm(request.POST)

        # check whether it's valid:
        if form.is_valid():
            #print(dir(form.data.values))
            call(form.cleaned_data['inline'])
            call(form.cleaned_data['outline'])
            return HttpResponseRedirect('/thanks/')
    # if a GET (or any other method) we'll create a blank form
    else:
        form = CallForm()
    return render(request, 'CallForm.html', {'form': form})

這在呼叫期間給了我一條錯誤消息:“發生應用程序錯誤。再見”

而且我也在調試器中得到了這個信息:“文檔第1行出錯:文件過早結束。”

任何想法?

好的,我知道了。 使安裝工作唯一需要做的就是我必須修改響應,在其中添加xml字符串,然后設置返回對象的content_type。

return HttpResponse(str(response),content_type='application/xml')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM