我想从服务器下载音频文件。
当我直接在服务器上访问要求用户名和密码的url时,我想通过cURL覆盖它
基本上,我想允许我的网络用户在我的网站上收听歌曲。我有其他网络的身份验证来这样做。目前,我的网站的用户首先要仔细检查,然后他们使用凭据登录我的网站,然后单击"播放"按钮,然后再次输入我提供给他们的用户名和密码(与我进行身份验证的同一网络)。
$url="https://example.com/abc.wav";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "userstring:passString");
curl_exec($ch);
curl_close($ch);
Direct URL after entering the username & password allowed me to listen the audio.
now how can I authenticate my web to access that URL by overriding authentication?
I want to download it and as well as play in the background after clicking on button "download" & "Play" respectively.
On the other hand is there any way that I can email that file without downloading or by downloading it
使用以下代码进行身份验证,您忘记设置标头
header("Content-Type: audio/mpeg");
$url = "clip.mp3"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "password");
curl_exec($ch);
header('Location: ' . $url);