Created
August 15, 2016 07:53
-
-
Save grokify/a5767c8f05c500750aa3a53ac3fbac77 to your computer and use it in GitHub Desktop.
RC Blog 2015-10 Call Recording API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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