简体   繁体   English

Twilio 调用错误的 url

[英]Twilio Making a call wrong url

So i am trying to make a call using twilio.所以我正在尝试使用 twilio 拨打电话。 I tried the example and it worked.我试过这个例子,它奏效了。

        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    Call call = Call.creator(
            new PhoneNumber("+xxxxxxxxxxxxx"),
            new PhoneNumber("+yyyyyyyyyyyyy"),
            new URI("http://demo.twilio.com/docs/voice.xml")


    )
            .setRecord(true)
            .create();

    System.out.println(call.getSid());

}

And now I want that when the clients answer the phone a voice massage appears and the clients say what it wants and the call ends.现在我希望当客户接听电话时出现语音消息,客户说出它想要的内容,然后通话结束。 To do that, this xml was created.为此,创建了这个 xml。

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say voice="woman">Please leave a message after the tone.</Say>
    <Record maxLength="20" />
</Response>

But when i try to use the url: "file:///C:/Users/user/Documents/NetBeansProjects/work/test.xml" THe program doesnt run and a error appears Exception in thread "main" com.twilio.exception.ApiException: Url is not a valid URL但是,当我尝试使用 url:“file:///C:/Users/user/Documents/NetBeansProjects/work/test.xml”时,该程序无法运行,并且线程“main”com.twilio 中出现异常。 exception.ApiException:Url 不是有效的 URL

Does twilio doesn't accept the file url? twilio 不接受文件 url 吗?

If so how can I do it?如果是这样我该怎么做? Thanks.谢谢。

Twilio developer evangelist here. Twilio 开发者传播者在这里。

For you to use TwiML, you will need to make sure that it is accessible by Twilio, as it's Twilio who will try to read that XML.要使用 TwiML,您需要确保 Twilio 可以访问它,因为 Twilio 将尝试读取该 XML。

I suggest either generating that TwiML from your application and making it available using something like ngrok , or just host that XML somewhere else that is accessible by Twilio.我建议从您的应用程序生成该 TwiML 并使用ngrok之类的东西使其可用,或者只是将该 XML 托管在 Twilio 可访问的其他地方。 You could host it in dropbox for example and just make it public, and as long as it's visible, you should be good!例如,您可以将其托管在 Dropbox 中,然后将其公开,只要它可见,您就应该做得很好!

Also, have a look at this to see how to generate TwiML from your app.此外,请查看 内容以了解如何从您的应用程序生成 TwiML。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM