Generate voice call using twilio

寵の児 提交于 2020-01-23 04:01:06

问题


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

Code snippet:

$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));

回答1:


Twilio developer evangelist here.

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.

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).

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

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.



来源:https://stackoverflow.com/questions/36312987/generate-voice-call-using-twilio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!