-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Download recording #515
Comments
I am same problem. `use Twilio\Rest\Client $twilio = new Client($sid, $token); recordings arguments add '.mp3', but '. json' at the end of url is forcibly added by the constructor of "Twilio\Rest\Api\V2010\Account\RecordingList" class's Constructor. |
@sh-ogawa Twilio document said:
https://www.twilio.com/docs/voice/api/recording#fetch-a-recording-media-file |
I know that. |
@sh-ogawa I don't know, too. Hope there will be other ways to do it |
This is not currently supported by the Twilio helper libraries. Adding it to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog. |
Hmm, unresolved for 2 years already... so we have to use hack like this: foreach ($fetchedInbound->recordings->read() as $recording) {
/** @var RecordingInstance $recording */
$uri = sprintf('https://api.twilio.com%s', str_replace('.json', '', $recording->uri));
...
} |
@jkabat I think this may is the only way at the current time |
@jkabat where have you put this hack in? Also, does it work while downloading audio recording from a video call? |
require __DIR__ . '/vendor/autoload.php';
// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;
// Your Account SID and Auth Token from twilio.com/console
$sid = '';
$token = '';
$twilio = new Client($sid, $token);
$RecordingSid = $_REQUEST['RecordingSid'];
$file_type = '.mp3'; // or use '.wav'
$recording = $twilio->recordings($RecordingSid)->fetch();
$context = stream_context_create(["http"=>["header"=>"Authorization: Basic ".base64_encode("{$sid}:{$token}")]]);
$uri = 'https://api.twilio.com'.str_replace('.json',$file_type,$recording->uri);
$recording_file = file_get_contents($uri,false,$context);
file_put_contents($RecordingSid.$file_type,$recording_file); //saves the file in the current directory |
Hello everybody,
Could you show me how can download the recording file to local drive?
Thanks & Best regard
The text was updated successfully, but these errors were encountered: