Reputation: 408
$client = new Services_Twilio($sid, $token);
$calls = $client->account->calls;
foreach($calls as $call){
?>
<audio controls><source src='<?php echo "https://api.twilio.com".$call->uri; ?>' type='audio/ogg'><source src='<?php echo "https://api.twilio.com".$call->uri; ?>' type='audio/mpeg'> Your browser does not support the audio tag.</audio>
<?
}
?>
I tried appending .mp3 to the URL, it did not worked!
Upvotes: 0
Views: 550
Reputation: 73075
Twilio developer evangelist here.
My guess here is that you are trying to list out audio elements for calls that you have recorded so that you can play them back. If that is the case, then you are not using the correct URI for the recording. $call->uri
will actually return the path of the API resource for the call itself.
Instead, you will need to list the recordings of the call and use the URLs returned there. Like so:
<?
$client = new Services_Twilio($sid, $token);
$calls = $client->account->calls;
foreach($calls as $call){
foreach($call->recordings as $recording){
?>
<audio controls>
<source src='<?php echo "https://api.twilio.com".$recording->uri; ?>' type='audio/wav'>
<source src='<?php echo "https://api.twilio.com".$recording->uri.".mp3"; ?>' type='audio/mpeg'>
Your browser does not support the audio tag.
</audio>
<?
}
}
?>
Upvotes: 1