Skip to content

Instantly share code, notes, and snippets.

@grokify
Created August 15, 2016 07:53
Show Gist options
  • Save grokify/a5767c8f05c500750aa3a53ac3fbac77 to your computer and use it in GitHub Desktop.
Save grokify/a5767c8f05c500750aa3a53ac3fbac77 to your computer and use it in GitHub Desktop.
RC Blog 2015-10 Call Recording API
$callLogRecords = $platform->get('/account/~/extension/~/call-log', array(
'type' => 'Voice',
'withRecording' => 'True'
))->json()->records;
foreach ($callLogRecords as $callLogRecord) {
// Retrieve recording media
$apiResponse = $platform->get($callLogRecord->recording->contentUri);
$id = $callLogRecord->recording->id;
// Save recording audio
$ext = ($apiResponse->response()->getHeader('Content-Type')[0] == 'audio/mpeg') ? 'mp3' : 'wav';
$fp = fopen("recording_${id}.${ext}", 'w');
fwrite($fp, $apiResponse->raw());
fclose($fp);
// Save recording metadata
file_put_contents("recording_${id}.json", json_encode($callLogRecord));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment