'twilio - how to make an outbound voice call in php
I have the below method. Currently is just calls up an external phone number and says "Welcome". I cannot understand how to connect a twilio number with an external phone number by voice? Lots of example of how to do text-to-voice but not much on voice to voice. Any pointers appreciated.
public function test_call(){
$this->account_sid = 'AC-account_sid';
$this->auth_token = 'myauth_token';
$this->client = new Client($this->account_sid, $this->auth_token);
$call = $this->client->account->calls->create(
'+81xxxxxxxxxx', // Destination phone number
'+81yyyyyyyyyy', // Valid Twilio phone number
array(
"record" => false,
"url" => "http://development.example.com/gomi.xml")
);
if($call) {
echo 'Call initiated successfully';
} else {
echo 'Call failed!';
}
}
Contents of gomi.xml
<Response>
<Say voice="alice">Welcome</Say>
</Response>
Solution 1:[1]
If you want to connect your call there to another number, then you need to look at the <Dial>
TwiML verb.
You could, for example, update your gomi.xml
to:
<Response>
<Dial>
<Number>+XXXXXXXXXXXX</Number>
</Dial>
</Response>
Then, when the initial call connects it would trigger another call to the number inside the <Number>
tags, connecting the two callers.
Take a look at the documentation for <Dial>
for more information.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | philnash |