使用 twilio 生成语音通话 [英] Generate voice call using twilio

查看:79
本文介绍了使用 twilio 生成语音通话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个使用 twilio api 的小应用程序,可以从我的 twilio 号码拨打任何电话号码.拨打电话后,移动端正在播放特定的音频片段.但我在通话的任何一方都没有得到任何真实的声音.请帮助我或给我一些有关如何使用 twilio api 在语音通话中获得语音的信息.谢谢,塔尼姆

I have developed a small application using twilio api to make call to any phone number from my twilio number. After dialing call is establishing and a specific audio clip is playing in mobile end. But I am not getting any real voice in any side of the call. Please help me or give me some information regarding how can i get voice in voice call using twilio api. Thanks, Tanim

代码片段:

$client = new Services_Twilio($AccountSid, $AuthToken);
$call = $client->account->calls->create("My Twilio Number", "Outgoing number", "demo.twilio.com/docs/voice.xml";, array());
var_dump($call->sid);
$response = new Services_Twilio_Twiml();
$response->say('Hello');
$response->play('api.twilio.com/cowbell.mp3';, array("loop" => 5));

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

当您通过 Twilio REST API 创建调用时,您传递了三个参数,您的Twilio 号码、您尝试拨打的号码和网址.

When you create a call through the Twilio REST API you pass three parameters, your Twilio number, the number you're trying to call and a URL.

当您呼叫的号码接听时,Twilio 会请求 URL 以询问如何处理呼叫.在您的示例中,您发送的 URL 是我们的演示 URL "demo.twilio.com/docs/voice.xml".您需要在您的应用程序中传递一个同样由您控制的 URL,以告诉 Twilio 如何处理该调用.该 URL 需要返回 TwiML,这是关于如何处理手机的 XML 描述打电话(或短信).

When the number you're calling picks up, Twilio requests the URL to ask what to do with the call. In your example, the URL you have sent is our demo URL "demo.twilio.com/docs/voice.xml". You need to pass a URL that is also controlled by you, in your application, to tell Twilio what to do with the call. That URL needs to return TwiML, which is an XML description of what to do with a phone call (or text message).

在您提供的代码片段中,您正在生成 TwiML 响应,但我看不到您如何使用它.

In your code snippet that you provided, you are generating a TwiML response, but I can't see how you're using it.

我建议您阅读使用 Twilio 拨打电话的快速入门指南这应该能让你快速了解这些东西是如何组合在一起的.然后查看 Twilio 教程 部分,以更深入地了解某些用例以及要执行的代码那些用例.

I recommend you work through the Quickstart guide for making phone calls with Twilio which should get you up to speed on how these things fit together. Then check out the Twilio Tutorials section to learn about certain use cases in more depth with the code to perform those use cases.

让我知道这是否有帮助.

Let me know if that helps at all.

这篇关于使用 twilio 生成语音通话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆