根据CrazyCall docs,我可以下载呼叫记录,因此我尝试使用PHP curl来获取它:
<?php
function records(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.crazycall.com/api/v1/calls/2/recording");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$headers = array();
$headers[] = "X-Api-Token: XCEFERlmvoj349jimXXXXXX";
$headers[] = "Account: WSXDEXXXXX.crazycall.com";
$headers[] = "Host: api.crazycall.com";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
return $result;
}
$sample = records();
header("Content-type: audio/wav");
header("Content-Disposition: attachment; filename=record.wav");
echo $sample;
?>
这很好用,但是现在我想在浏览器中播放音频文件而不是下载它,我尝试使用如下音频标签:
<html><body>
<audio controls autoplay>
<source src="<?php echo $sample; ?>" type="audio/wav">
Your browser does not support the audio element.
</audio>
</body></html>
但是它不起作用,如何解决?
我需要您的帮助
答案 0 :(得分:0)
问题出在Content-Disposition: attachment;
告诉浏览器下载文件。
尝试根据https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition将attachment
更改为inline