使用twilio生成语音呼叫 [英] Generate voice call using twilio

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

问题描述

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

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号码,您要呼叫的号码和URL.

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天全站免登陆